/// <inheritdoc/> public async Task <GrpcListSwitchesReply> ListSwitchesAsync(GrpcListSwitchesRequest request, CallContext context = default) { await SyncContext.Clear; try { return(new GrpcListSwitchesReply(switches: hyperv.ListSwitches().Select(@switch => @switch.ToProto()).ToList())); } catch (Exception e) { return(new GrpcListSwitchesReply(e)); } }
/// <summary> /// Returns the virtual network switches. /// </summary> /// <returns>The list of switches.</returns> public List <VirtualSwitch> ListSwitches() { if (isAdmin) { return(hypervClient.ListSwitches()); } else { var request = new GrpcListSwitchesRequest(); var reply = desktopService.ListSwitchesAsync(request).Result; reply.Error.EnsureSuccess(); return(reply.Switches.Select(@switch => @switch.ToLocal()).ToList()); } }