private ProfileDocument(XDocument root) { if (root == null) { return; } this.Root = root; Name = Root.Elements().First().Elements(XName.Get("name", Namespace)).FirstOrDefault()?.Value; var ssidElement = Root.Descendants(XName.Get("SSID", Namespace)).FirstOrDefault(); var ssidHexString = ssidElement?.Descendants(XName.Get("hex", Namespace)).FirstOrDefault()?.Value; var ssidHexBytes = HexadecimalStringConverter.ToBytes(ssidHexString); var ssidNameString = ssidElement?.Descendants(XName.Get("name", Namespace)).FirstOrDefault()?.Value; Ssid = new NetworkIdentifier(ssidHexBytes, ssidNameString); var connectionTypeString = Root.Descendants(XName.Get("connectionType", Namespace)).FirstOrDefault()?.Value; if (!BssTypeConverter.TryParse(connectionTypeString, out BssType bssType)) { return; } this.BssType = bssType; AuthenticationString = Root.Descendants(XName.Get("authentication", Namespace)).FirstOrDefault()?.Value; if (!AuthenticationMethodConverter.TryParse(AuthenticationString, out AuthenticationMethod authentication)) { return; } this.Authentication = authentication; EncryptionString = Root.Descendants(XName.Get("encryption", Namespace)).FirstOrDefault()?.Value; if (!EncryptionTypeConverter.TryParse(EncryptionString, out EncryptionType encryption)) { return; } this.Encryption = encryption; //Debug.WriteLine("SSID: {0}, BssType: {1}, Authentication: {2}, Encryption: {3}", // Ssid, // BssType, // Authentication, // Encryption); _connectionModeElement = Root.Descendants(XName.Get("connectionMode", Namespace)).FirstOrDefault(); if (_connectionModeElement == null) { return; } _autoSwitchElement = Root.Descendants(XName.Get("autoSwitch", Namespace)).FirstOrDefault(); IsValid = true; }
/// <summary> /// Constructor /// </summary> public AvailableNetworkPack( InterfaceInfo interfaceInfo, NetworkIdentifier ssid, BssType bssType, int signalQuality, bool isSecurityEnabled, string profileName) { this.Interface = interfaceInfo; this.Ssid = ssid; this.BssType = bssType; this.SignalQuality = signalQuality; this.IsSecurityEnabled = isSecurityEnabled; this.ProfileName = profileName; }
/// <summary> /// Constructor /// </summary> public BssNetworkPack( InterfaceInfo interfaceInfo, NetworkIdentifier ssid, BssType bssType, NetworkIdentifier bssid, int signalStrength, int linkQuality, int frequency, int channel) { this.Interface = interfaceInfo; this.Ssid = ssid; this.BssType = bssType; this.Bssid = bssid; this.SignalStrength = signalStrength; this.LinkQuality = linkQuality; this.Frequency = frequency; this.Channel = channel; }