private ProfileDocument(XDocument root)
        {
            if (root is 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 is null)
            {
                return;
            }

            _autoSwitchElement = Root.Descendants(XName.Get("autoSwitch", Namespace)).FirstOrDefault();

            IsValid = true;
        }
        internal static IEnumerable <AvailableNetworkPack> EnumerateAvailableNetworks(Base.WlanClient client)
        {
            using (var container = new DisposableContainer <Base.WlanClient>(client))
            {
                var interfaceInfoList = Base.GetInterfaceInfoList(container.Content.Handle);

                foreach (var interfaceInfo in interfaceInfoList.Select(x => new InterfaceInfo(container.Content.Handle, x)))
                {
                    var availableNetworkList = Base.GetAvailableNetworkList(container.Content.Handle, interfaceInfo.Id);
                    foreach (var availableNetwork in availableNetworkList)
                    {
                        if (!BssTypeConverter.TryConvert(availableNetwork.dot11BssType, out BssType bssType))
                        {
                            continue;
                        }

                        if (!EncryptionTypeConverter.TryConvert(availableNetwork.dot11DefaultCipherAlgorithm, out EncryptionType encryptionType))
                        {
                            continue;
                        }

                        if (!AuthTypeConverter.TryConvert(availableNetwork.dot11DefaultAuthAlgorithm, out AuthType authType))
                        {
                            continue;
                        }

                        //Debug.WriteLine("Interface: {0}, SSID: {1}, Signal: {2}, Security: {3}",
                        //	interfaceInfo.Description,
                        //	availableNetwork.dot11Ssid,
                        //	availableNetwork.wlanSignalQuality,
                        //	availableNetwork.bSecurityEnabled);

                        yield return(new AvailableNetworkPack(
                                         interfaceInfo: interfaceInfo,
                                         ssid: new NetworkIdentifier(availableNetwork.dot11Ssid.ToBytes(), availableNetwork.dot11Ssid.ToString(), availableNetwork.dot11Ssid.uSSIDLength),
                                         bssType: bssType,
                                         signalQuality: (int)availableNetwork.wlanSignalQuality,
                                         isSecurityEnabled: availableNetwork.bSecurityEnabled,
                                         profileName: availableNetwork.strProfileName,
                                         cipherAlgorithm: encryptionType,
                                         authAlgorithm: authType));
                    }
                }
            }
        }