-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetworkInfo.cs
77 lines (64 loc) · 2.11 KB
/
NetworkInfo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WifiHotspotDotNet
{
public class NetworkInfo
{
private List<String> Data;
public String Mode { get; }
public String SSID { get; }
public String Authentication { get; }
public String Cipher { get; }
public String BSSID { get; }
public String RadioType { get; }
public int MaxClients { get; }
public int Channel { get; }
public int NumberClients { get; }
public NetworkInfo(List<String> data)
{
this.Data = data;
this.Mode = GetDataValue("Mode");
this.SSID = GetDataValue("SSID name", true);
this.Authentication = GetDataValue("Authentication");
this.Cipher = GetDataValue("Cipher");
this.BSSID = GetDataValue("BSSID");
this.RadioType = GetDataValue("Radio type");
try
{
this.MaxClients = Convert.ToInt32(GetDataValue("Max number of clients"));
}
catch (FormatException) { }
try
{
this.Channel = Convert.ToInt32(GetDataValue("Channel"));
}
catch (FormatException) { }
try
{
this.NumberClients = Convert.ToInt32(GetDataValue("Number of clients"));
}
catch (FormatException) { }
}
private string GetDataValue(String name, bool removeQuotes = false)
{
foreach (String s in Data)
{
if (s.StartsWith(" " + name))
{
int startIndex = s.IndexOf(":") + 1;
string value = s.Substring(startIndex, s.Length - startIndex);
if (removeQuotes)
{
value = value.Remove(0, 2);
value = value.Remove(value.Length - 1, 1);
}
return value;
}
}
return "";
}
}
}