diff options
Diffstat (limited to 'src/csharp/Grpc.Core/ServerServiceDefinition.cs')
-rw-r--r-- | src/csharp/Grpc.Core/ServerServiceDefinition.cs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/csharp/Grpc.Core/ServerServiceDefinition.cs b/src/csharp/Grpc.Core/ServerServiceDefinition.cs index 94b0a320c3..deb1431ca3 100644 --- a/src/csharp/Grpc.Core/ServerServiceDefinition.cs +++ b/src/csharp/Grpc.Core/ServerServiceDefinition.cs @@ -40,6 +40,8 @@ namespace Grpc.Core { /// <summary> /// Mapping of method names to server call handlers. + /// Normally, the <c>ServerServiceDefinition</c> objects will be created by the <c>BindService</c> factory method + /// that is part of the autogenerated code for a protocol buffers service definition. /// </summary> public class ServerServiceDefinition { @@ -58,21 +60,41 @@ namespace Grpc.Core } } + /// <summary> + /// Creates a new builder object for <c>ServerServiceDefinition</c>. + /// </summary> + /// <param name="serviceName">The service name.</param> + /// <returns>The builder object.</returns> public static Builder CreateBuilder(string serviceName) { return new Builder(serviceName); } + /// <summary> + /// Builder class for <see cref="ServerServiceDefinition"/>. + /// </summary> public class Builder { readonly string serviceName; readonly Dictionary<string, IServerCallHandler> callHandlers = new Dictionary<string, IServerCallHandler>(); + /// <summary> + /// Creates a new instance of builder. + /// </summary> + /// <param name="serviceName">The service name.</param> public Builder(string serviceName) { this.serviceName = serviceName; } + /// <summary> + /// Adds a definitions for a single request - single response method. + /// </summary> + /// <typeparam name="TRequest">The request message class.</typeparam> + /// <typeparam name="TResponse">The response message class.</typeparam> + /// <param name="method">The method.</param> + /// <param name="handler">The method handler.</param> + /// <returns>This builder instance.</returns> public Builder AddMethod<TRequest, TResponse>( Method<TRequest, TResponse> method, UnaryServerMethod<TRequest, TResponse> handler) @@ -83,6 +105,14 @@ namespace Grpc.Core return this; } + /// <summary> + /// Adds a definitions for a client streaming method. + /// </summary> + /// <typeparam name="TRequest">The request message class.</typeparam> + /// <typeparam name="TResponse">The response message class.</typeparam> + /// <param name="method">The method.</param> + /// <param name="handler">The method handler.</param> + /// <returns>This builder instance.</returns> public Builder AddMethod<TRequest, TResponse>( Method<TRequest, TResponse> method, ClientStreamingServerMethod<TRequest, TResponse> handler) @@ -93,6 +123,14 @@ namespace Grpc.Core return this; } + /// <summary> + /// Adds a definitions for a server streaming method. + /// </summary> + /// <typeparam name="TRequest">The request message class.</typeparam> + /// <typeparam name="TResponse">The response message class.</typeparam> + /// <param name="method">The method.</param> + /// <param name="handler">The method handler.</param> + /// <returns>This builder instance.</returns> public Builder AddMethod<TRequest, TResponse>( Method<TRequest, TResponse> method, ServerStreamingServerMethod<TRequest, TResponse> handler) @@ -103,6 +141,14 @@ namespace Grpc.Core return this; } + /// <summary> + /// Adds a definitions for a bidirectional streaming method. + /// </summary> + /// <typeparam name="TRequest">The request message class.</typeparam> + /// <typeparam name="TResponse">The response message class.</typeparam> + /// <param name="method">The method.</param> + /// <param name="handler">The method handler.</param> + /// <returns>This builder instance.</returns> public Builder AddMethod<TRequest, TResponse>( Method<TRequest, TResponse> method, DuplexStreamingServerMethod<TRequest, TResponse> handler) @@ -113,6 +159,10 @@ namespace Grpc.Core return this; } + /// <summary> + /// Creates an immutable <c>ServerServiceDefinition</c> from this builder. + /// </summary> + /// <returns>The <c>ServerServiceDefinition</c> object.</returns> public ServerServiceDefinition Build() { return new ServerServiceDefinition(callHandlers); |