public async Task <IEnumerable <ProfileItem> > GetProfilesAsync(bool isLatest, TimeSpan timeoutDuration) { var interfacePacks = (await Netsh.GetInterfacesAsync().ConfigureAwait(false)) .ToArray(); // ToArray method is necessary. var networkPacks = (await Netsh.GetNetworksAsync().ConfigureAwait(false)) .ToArray(); // ToArray method is necessary. var profilePacks = await Netsh.GetProfilesAsync().ConfigureAwait(false); return(from profilePack in profilePacks let networkPack = networkPacks.FirstOrDefault(x => x.InterfaceName.Equals(profilePack.InterfaceName, StringComparison.Ordinal) && x.Ssid.Equals(profilePack.Ssid, StringComparison.Ordinal)) from interfacePack in interfacePacks where profilePack.InterfaceName.Equals(interfacePack.Name, StringComparison.Ordinal) select new ProfileItem( name: profilePack.Name, interfaceGuid: interfacePack.Guid, interfaceName: profilePack.InterfaceName, interfaceDescription: interfacePack.Description, authentication: ConvertToAuthentication(profilePack.Authentication), encryption: ConvertToEncryption(profilePack.Encryption), position: profilePack.Position, isAutomatic: profilePack.IsAutomatic, signal: (networkPack?.Signal ?? 0), isConnected: (interfacePack.IsConnected && profilePack.Name.Equals(interfacePack.ProfileName, StringComparison.Ordinal)))); }
public async Task <bool> DisconnectAsync(ProfileItem profileItem, TimeSpan timeoutDuration) { if (profileItem == null) { throw new ArgumentNullException(nameof(profileItem)); } return(await Netsh.DisconnectAsync(profileItem.InterfaceName)); }
public async Task <bool> DeleteProfileAsync(ProfileItem profileItem) { if (profileItem == null) { throw new ArgumentNullException(nameof(profileItem)); } return(await Netsh.DeleteProfileAsync(profileItem.Name, profileItem.InterfaceName)); }
public async Task <bool> SetProfileParameterAsync(ProfileItem profileItem) { if (profileItem == null) { throw new ArgumentNullException(nameof(profileItem)); } return(await Netsh.SetProfileParameterAsync(profileItem.InterfaceName, profileItem.Name, profileItem.IsAutoConnectionEnabled, profileItem.IsAutoSwitchEnabled)); }
public async Task <bool> ConnectNetworkAsync(ProfileItem profileItem, TimeSpan timeout) { if (profileItem == null) { throw new ArgumentNullException(nameof(profileItem)); } return(await Netsh.ConnectNetworkAsync(profileItem.InterfaceName, profileItem.Name)); }
public async Task <bool> SetProfilePositionAsync(ProfileItem profileItem, int position) { if (profileItem == null) { throw new ArgumentNullException(nameof(profileItem)); } if (position < 0) { throw new ArgumentOutOfRangeException(nameof(position)); } return(await Netsh.SetProfilePositionAync(profileItem.Name, profileItem.InterfaceName, position)); }