示例#1
0
        public static SomeObjectProto CopyToProto(SomeObject value)
        {
            var result = new SomeObjectProto
            {
                DateScalar   = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(value.DateScalar),
                Int32Scalar  = value.Int32Scalar,
                SingleScalar = value.SingleScalar
            };

            if (value.StringScalar != null)
            {
                result.StringScalar = value.StringScalar;
            }

            if (value.SingleArray != null)
            {
                result.SingleArray.Add(value.SingleArray);
            }

            if (value.Int32Array != null)
            {
                result.Int32Array.Add(value.Int32Array);
            }

            if (value.DoubleArray != null)
            {
                result.DoubleArray.Add(value.DoubleArray);
            }

            return(result);
        }
示例#2
0
        public NativeGrpcClientCallTest(SomeObject payload)
        {
            _payload = DomainExtensions.CopyToProto(payload);

            _httpHandler = new StubHttpMessageHandler(_payload);
            _channel     = GrpcChannel.ForAddress("http://localhost", new GrpcChannelOptions {
                HttpHandler = _httpHandler
            });

            _proxy = new TestServiceNative.TestServiceNativeClient(_channel);
        }
示例#3
0
        public NativeGrpcCombinedCallTest(SomeObject payload)
        {
            _payload = DomainExtensions.CopyToProto(payload);
            _server  = new TestServer(new WebHostBuilder().UseStartup <Startup>());
            _client  = _server.CreateClient();

            _channel = GrpcChannel.ForAddress("http://localhost", new GrpcChannelOptions {
                HttpClient = _client
            });

            _proxy = new TestServiceNative.TestServiceNativeClient(_channel);
        }
示例#4
0
        public ServiceModelGrpcProtoClientCallTest(SomeObject payload)
        {
            _payload     = DomainExtensions.CopyToProto(payload);
            _httpHandler = new StubHttpMessageHandler(GoogleProtoMarshallerFactory.Default, new Message <SomeObjectProto>(_payload));
            _channel     = GrpcChannel.ForAddress("http://localhost", new GrpcChannelOptions {
                HttpHandler = _httpHandler
            });

            var clientFactory = new ClientFactory(new ServiceModelGrpcClientOptions {
                MarshallerFactory = GoogleProtoMarshallerFactory.Default
            });

            _proxy = clientFactory.CreateClient <ITestService>(_channel);
        }
示例#5
0
        public ServiceModelGrpcProtoCombinedCallTest(SomeObject payload)
        {
            _payload = DomainExtensions.CopyToProto(payload);

            var builder = new WebHostBuilder().UseStartup <Startup>();

            _server = new TestServer(builder);
            _client = _server.CreateClient();

            _channel = GrpcChannel.ForAddress("http://localhost", new GrpcChannelOptions {
                HttpClient = _client
            });
            _clientFactory = new ClientFactory(new ServiceModelGrpcClientOptions {
                MarshallerFactory = GoogleProtoMarshallerFactory.Default
            });
            _proxy = _clientFactory.CreateClient <ITestService>(_channel);
        }
示例#6
0
 public override Task <SomeObjectProto> PingPong(SomeObjectProto request, ServerCallContext context)
 {
     return(Task.FromResult(request));
 }
示例#7
0
 public Task <SomeObjectProto> PingPongProto(SomeObjectProto value)
 {
     return(Task.FromResult(value));
 }