TMessage IRpcDispatch.CallMethod <TMessage, TBuilder>(string method, IMessageLite request,
                                                       IBuilderLite <TMessage, TBuilder> response)
 {
     byte[] rawResponse = _wire.Execute(method, request.ToByteArray());
     response.MergeFrom(rawResponse);
     return(response.Build());
 }
예제 #2
0
 public virtual TMessage CallMethod <TMessage, TBuilder>(string method, IMessageLite request,
                                                         IBuilderLite <TMessage, TBuilder> response)
     where TMessage : IMessageLite <TMessage, TBuilder>
     where TBuilder : IBuilderLite <TMessage, TBuilder>
 {
     CallService(method, request, response);
     return(response.Build());
 }
            TMessage IRpcDispatch.CallMethod <TMessage, TBuilder>(string method, IMessageLite request,
                                                                  IBuilderLite <TMessage, TBuilder> response)
            {
                MemoryStream input  = new MemoryStream();
                MemoryStream output = new MemoryStream();

                //Write to _mimeType format
                Extensions.WriteTo(request, Options, _mimeType, input);

                input.Position = 0;
                _wire.Execute(method, _mimeType, input, _mimeType, output);

                //Read from _mimeType format
                output.Position = 0;
                Extensions.MergeFrom(response, Options, _mimeType, output);

                return(response.Build());
            }
예제 #4
0
            public TMessage CallMethod <TMessage, TBuilder>(string method, IMessageLite request, IBuilderLite <TMessage, TBuilder> response)
                where TMessage : IMessageLite <TMessage, TBuilder>
                where TBuilder : IBuilderLite <TMessage, TBuilder>
            {
                Stream            stream = new MemoryStream();
                CodedOutputStream output = CodedOutputStream.CreateInstance(stream);

                output.WriteStringNoTag(method);
                request.WriteTo(output);
                output.Flush();

                stream.Position = 0;
                stream          = _channel.Invoke(stream);
                CodedInputStream input = CodedInputStream.CreateInstance(stream);

                response.MergeFrom(input);
                return(response.Build());
            }