예제 #1
0
        /// <summary>
        /// Creates the RPC method description.
        /// </summary>
        /// <typeparam name="TRequest">The type of the request.</typeparam>
        /// <typeparam name="TResponse">The type of the response.</typeparam>
        /// <param name="builder">The service builder.</param>
        /// <param name="serviceName">The service name.</param>
        /// <param name="handler">The method information.</param>
        /// <param name="marshallerFactory">The factory of the marshaller.</param>
        /// <param name="serviceInstance">The service instance.</param>
        /// <returns>The method description.</returns>
        private static ServerServiceDefinition.Builder AddStructMethodCore <TRequest, TResponse>(ServerServiceDefinition.Builder builder, string serviceName, RpcMethodHandlerInfo handler, IRpcMarshallerFactory marshallerFactory, object serviceInstance)
        {
            Method <TRequest, TResponse> method = new Method <TRequest, TResponse>(handler.MethodType, serviceName, handler.Handler.Name, marshallerFactory.GetMarshaller <TRequest>(), marshallerFactory.GetMarshaller <TResponse>());

            switch (handler.MethodType)
            {
            case MethodType.Unary:
                return(builder.AddStructMethod(method, (StructUnaryServerMethod <TRequest, TResponse>)handler.Handler.CreateDelegate(typeof(StructUnaryServerMethod <TRequest, TResponse>), serviceInstance)));

            case MethodType.ClientStreaming:
                return(builder.AddStructMethod(method, (StructClientStreamingServerMethod <TRequest, TResponse>)handler.Handler.CreateDelegate(typeof(StructClientStreamingServerMethod <TRequest, TResponse>), serviceInstance)));

            case MethodType.ServerStreaming:
                return(builder.AddStructMethod(method, (StructServerStreamingServerMethod <TRequest, TResponse>)handler.Handler.CreateDelegate(typeof(StructServerStreamingServerMethod <TRequest, TResponse>), serviceInstance)));

            case MethodType.DuplexStreaming:
                return(builder.AddStructMethod(method, (StructDuplexStreamingServerMethod <TRequest, TResponse>)handler.Handler.CreateDelegate(typeof(StructDuplexStreamingServerMethod <TRequest, TResponse>), serviceInstance)));

            default:
                return(builder);
            }
        }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="TRequest"></typeparam>
 /// <typeparam name="TResponse"></typeparam>
 /// <param name="method"></param>
 /// <param name="handler"></param>
 protected void AddStructMethod <TRequest, TResponse>(Method <TRequest, TResponse> method, StructUnaryServerMethod <TRequest, TResponse> handler)
 {
     m_Service = m_Service.AddStructMethod(method, handler);
 }