Example #1
0
 /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the  service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, WorkerServiceBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_RunServer, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod <global::Grpc.Testing.ServerArgs, global::Grpc.Testing.ServerStatus>(serviceImpl.RunServer));
     serviceBinder.AddMethod(__Method_RunClient, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod <global::Grpc.Testing.ClientArgs, global::Grpc.Testing.ClientStatus>(serviceImpl.RunClient));
     serviceBinder.AddMethod(__Method_CoreCount, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Grpc.Testing.CoreRequest, global::Grpc.Testing.CoreResponse>(serviceImpl.CoreCount));
     serviceBinder.AddMethod(__Method_QuitWorker, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Grpc.Testing.Void, global::Grpc.Testing.Void>(serviceImpl.QuitWorker));
 }
Example #2
0
 /// <summary>Register service method implementations with a service binder. Useful when customizing the service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, WorkerServiceBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_RunServer, serviceImpl.RunServer);
     serviceBinder.AddMethod(__Method_RunClient, serviceImpl.RunClient);
     serviceBinder.AddMethod(__Method_CoreCount, serviceImpl.CoreCount);
     serviceBinder.AddMethod(__Method_QuitWorker, serviceImpl.QuitWorker);
 }
Example #3
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(WorkerServiceBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_RunServer, serviceImpl.RunServer)
            .AddMethod(__Method_RunClient, serviceImpl.RunClient)
            .AddMethod(__Method_CoreCount, serviceImpl.CoreCount)
            .AddMethod(__Method_QuitWorker, serviceImpl.QuitWorker).Build());
 }
Example #4
0
     /// <summary>Creates service definition that can be registered with a server</summary>
 #pragma warning disable 0618
     public static ServerServiceDefinition BindService(WorkerServiceBase serviceImpl)
 #pragma warning restore 0618
     {
         return(ServerServiceDefinition.CreateBuilder(__ServiceName)
                .AddMethod(__Method_RunServer, serviceImpl.RunServer)
                .AddMethod(__Method_RunClient, serviceImpl.RunClient)
                .AddMethod(__Method_CoreCount, serviceImpl.CoreCount)
                .AddMethod(__Method_QuitWorker, serviceImpl.QuitWorker).Build());
     }
Example #5
0
        public Task <IActionResult> StopService(string resourceName, string asset)
        {
            string msg = null;

            return(this.ResultAsync(async() =>
            {
                ScanModel scan = new ScanModel {
                    ResourceName = resourceName, Asset = asset
                };
                WorkerServiceBase worker = WorkerServiceList.Instance.Find(scan);
                if (null != worker)
                {
                    await worker.Stop();
                    return !worker.IsRunning;
                }
                else
                {
                    msg = "The service not found.";
                }

                return false;
            }, msg));
        }