/// <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, StructDuplexStreamingServerMethod <TRequest, TResponse> handler) { m_Service = m_Service.AddStructMethod(method, handler); }
/// <summary> /// Adds a definition for a duplex streaming method without type restrictions. /// </summary> /// <typeparam name="TRequest">The type of the request.</typeparam> /// <typeparam name="TResponse">The type of the response.</typeparam> /// <param name="builder"></param> /// <param name="method"></param> /// <param name="handler"></param> /// <returns></returns> public static ServerServiceDefinition.Builder AddStructMethod <TRequest, TResponse>(this ServerServiceDefinition.Builder builder, Method <TRequest, TResponse> method, StructDuplexStreamingServerMethod <TRequest, TResponse> handler) { Task func(IAsyncStreamReader <byte[]> requestStream, IServerStreamWriter <byte[]> responseStream, ServerCallContext context) { return(handler( requestStream.Convert(bytes => method.RequestMarshaller.Deserializer(bytes)) , responseStream.ConvertResponse(method.ResponseMarshaller.Serializer) , context )); }; return(builder.AddMethod(s_StructMethodCache.GetMethod(method), func)); }