Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. private async Task<bool> CheckEnable()
  2. {
  3. var allInterfaces = await Sockets.Plugin.CommsInterface.GetAllInterfacesAsync();
  4. var enableInterfaces = allInterfaces.Where(ci => ci.IsUsable && !ci.IsLoopback && (ci.ConnectionStatus == Sockets.Plugin.Abstractions.CommsInterfaceStatus.Connected || ci.ConnectionStatus == Sockets.Plugin.Abstractions.CommsInterfaceStatus.Unknown));
  5. this.Interfaces.Clear();
  6. foreach (var item in enableInterfaces)
  7. {
  8. this.Interfaces.Add(new TNetworkInterface() { Name = (item.Name == "{ unknown }" ? item.IpAddress : item.Name), IpAddress = item.IpAddress });
  9. }
  10. var isEnable = (this.Interfaces.Count() > 0);
  11. if (isEnable)
  12. {
  13. this.SelectedInterface = this.Interfaces[0];
  14. }
  15. return isEnable;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement