Skip to content

Commit 6d7c707

Browse files
committed
Added navigator
1 parent 9563ba5 commit 6d7c707

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

AngleSharp.Scripting.JavaScript/AngleSharp.Scripting.JavaScript.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<Compile Include="DomConstructorInstance.cs" />
5656
<Compile Include="DomConstructors.cs" />
5757
<Compile Include="DomEventInstance.cs" />
58+
<Compile Include="Dom\Navigator.cs" />
5859
<Compile Include="Dom\RequesterState.cs" />
5960
<Compile Include="Dom\XmlHttpRequest.cs" />
6061
<Compile Include="Dom\XmlHttpRequestEventTarget.cs" />
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
namespace AngleSharp.Scripting.JavaScript.Dom
2+
{
3+
using AngleSharp.Dom.Navigator;
4+
using System;
5+
using System.Linq;
6+
using System.Net.NetworkInformation;
7+
8+
sealed class Navigator : INavigator
9+
{
10+
public String Name
11+
{
12+
get { return "Netscape"; }
13+
}
14+
15+
public String Platform
16+
{
17+
get { return Environment.OSVersion.VersionString; }
18+
}
19+
20+
public String UserAgent
21+
{
22+
get { return "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36 OPR/32.0.1948.19 (Edition beta)"; }
23+
}
24+
25+
public String Version
26+
{
27+
get { return "1.0.0"; }
28+
}
29+
30+
public Boolean IsContentHandlerRegistered(String mimeType, String url)
31+
{
32+
return false;
33+
}
34+
35+
public Boolean IsProtocolHandlerRegistered(String scheme, String url)
36+
{
37+
return false;
38+
}
39+
40+
public void RegisterContentHandler(String mimeType, String url, String title)
41+
{
42+
}
43+
44+
public void RegisterProtocolHandler(String scheme, String url, String title)
45+
{
46+
}
47+
48+
public void UnregisterContentHandler(String mimeType, String url)
49+
{
50+
}
51+
52+
public void UnregisterProtocolHandler(String scheme, String url)
53+
{
54+
}
55+
56+
public void WaitForStorageUpdates()
57+
{
58+
}
59+
60+
public Boolean IsOnline
61+
{
62+
get
63+
{
64+
if (NetworkInterface.GetIsNetworkAvailable())
65+
{
66+
var adapters = NetworkInterface.GetAllNetworkInterfaces().Where(m => m.OperationalStatus == OperationalStatus.Up);
67+
68+
foreach (var adapter in adapters)
69+
{
70+
if (adapter.NetworkInterfaceType != NetworkInterfaceType.Tunnel &&
71+
adapter.NetworkInterfaceType != NetworkInterfaceType.Loopback)
72+
{
73+
var statistic = adapter.GetIPv4Statistics();
74+
75+
if (statistic.BytesReceived > 0 && statistic.BytesSent > 0)
76+
return true;
77+
}
78+
}
79+
}
80+
81+
return false; ;
82+
}
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)