internal static IEnumerable <ProfilePack> EnumerateProfiles(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(x))) { var interfaceIsConnected = (interfaceInfo.State == InterfaceState.Connected); var interfaceIsRadioOn = interfaceIsConnected || IsInterfaceRadioOn(container.Content, interfaceInfo.Id); var availableNetworkList = Base.GetAvailableNetworkList(container.Content.Handle, interfaceInfo.Id) .Where(x => !string.IsNullOrWhiteSpace(x.strProfileName)) .ToArray(); var connection = Base.GetConnectionAttributes(container.Content.Handle, interfaceInfo.Id); var profileInfoList = Base.GetProfileInfoList(container.Content.Handle, interfaceInfo.Id); int position = 0; foreach (var profileInfo in profileInfoList) { var availableNetwork = availableNetworkList.FirstOrDefault(x => string.Equals(x.strProfileName, profileInfo.strProfileName, StringComparison.Ordinal)); var signalQuality = (int)availableNetwork.wlanSignalQuality; var profileIsConnected = interfaceIsConnected && string.Equals(connection.strProfileName, profileInfo.strProfileName, StringComparison.Ordinal); var profileXml = Base.GetProfile(container.Content.Handle, interfaceInfo.Id, profileInfo.strProfileName, out uint profileTypeFlag); if (string.IsNullOrWhiteSpace(profileXml)) { continue; } if (!ProfileTypeConverter.TryConvert(profileTypeFlag, out ProfileType profileType)) { continue; } //Debug.WriteLine("Interface: {0}, Profile: {1}, Position: {2}, RadioOn: {3}, Signal: {4}, Connected: {5}", // interfaceInfo.Description, // profileInfo.strProfileName, // position, // interfaceIsRadioOn, // signalQuality, // profileIsConnected); yield return(new ProfilePack( name: profileInfo.strProfileName, interfaceInfo: interfaceInfo, profileType: profileType, profileXml: profileXml, position: position++, isRadioOn: interfaceIsRadioOn, signalQuality: signalQuality, isConnected: profileIsConnected)); } } } }
internal static IEnumerable <ProfilePack> EnumerateProfiles(Base.WlanClient client) { using var container = new DisposableContainer <Base.WlanClient>(client); foreach (var interfaceInfo in EnumerateInterfaces(container.Content)) { int position = 0; foreach (var profileInfo in Base.GetProfileInfoList(container.Content.Handle, interfaceInfo.Id)) { var profileXml = Base.GetProfile(container.Content.Handle, interfaceInfo.Id, profileInfo.strProfileName, out uint profileTypeFlag); if (string.IsNullOrWhiteSpace(profileXml)) { continue; } if (!ProfileTypeConverter.TryConvert(profileTypeFlag, out ProfileType profileType)) { continue; } yield return(new ProfilePack( name: profileInfo.strProfileName, interfaceInfo: interfaceInfo, profileType: profileType, profileXml: profileXml, position: position++)); } } }
internal static IEnumerable <ProfileRadioPack> EnumerateProfileRadios(Base.WlanClient client) { using (var container = new DisposableContainer <Base.WlanClient>(client)) { foreach (var interfaceConnectionInfo in EnumerateInterfaceConnections(container.Content)) { var availableNetworkGroups = EnumerateAvailableNetworkGroups(container.Content, interfaceConnectionInfo) .Where(x => !string.IsNullOrWhiteSpace(x.ProfileName)) .ToArray(); int position = 0; foreach (var profileInfo in Base.GetProfileInfoList(container.Content.Handle, interfaceConnectionInfo.Id)) { var profileXml = Base.GetProfile(container.Content.Handle, interfaceConnectionInfo.Id, profileInfo.strProfileName, out uint profileTypeFlag); if (string.IsNullOrWhiteSpace(profileXml)) { continue; } if (!ProfileTypeConverter.TryConvert(profileTypeFlag, out ProfileType profileType)) { continue; } var availableNetworkGroup = availableNetworkGroups.FirstOrDefault(x => string.Equals(x.ProfileName, profileInfo.strProfileName, StringComparison.Ordinal)); yield return(new ProfileRadioPack( name: profileInfo.strProfileName, interfaceInfo: interfaceConnectionInfo, profileType: profileType, profileXml: profileXml, position: position++, signalQuality: (availableNetworkGroup?.SignalQuality ?? 0), linkQuality: (availableNetworkGroup?.LinkQuality ?? 0), frequency: (availableNetworkGroup?.Frequency ?? 0), band: (availableNetworkGroup?.Band ?? 0), channel: (availableNetworkGroup?.Channel ?? 0))); } } } }