Esempio n. 1
0
        /// <inheritdoc/>
        public async Task <GrpcListNatsReply> ListNatsAsync(GrpcListNatsRequest request, CallContext context = default)
        {
            await SyncContext.Clear;

            try
            {
                return(new GrpcListNatsReply(nats: hyperv.ListNats().Select(nat => nat.ToProto()).ToList()));
            }
            catch (Exception e)
            {
                return(new GrpcListNatsReply(e));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Lists the virtual NATs.
        /// </summary>
        /// <returns>A list of <see cref="VirtualNat"/>.</returns>
        public List <VirtualNat> ListNats()
        {
            if (isAdmin)
            {
                return(hypervClient.ListNats());
            }
            else
            {
                var request = new GrpcListNatsRequest();
                var reply   = desktopService.ListNatsAsync(request).Result;

                reply.Error.EnsureSuccess();

                return(reply.Nats.Select(nat => nat.ToLocal()).ToList());
            }
        }