Пример #1
0
        private static async Task Run()
        {
            // create gRPC channel
            var channel = new Channel("localhost", 5000, ChannelCredentials.Insecure);

            // register IGreeter proxy generated by ServiceModel.Grpc.DesignTime
            DefaultClientFactory.AddGreeterClient();

            // create IGreeter client proxy
            var client = DefaultClientFactory.CreateClient <IGreeter>(channel);

            var person = new Person {
                FirstName = "John", SecondName = "X"
            };

            var greet1 = await client.SayHelloAsync(person.FirstName, person.SecondName);

            Console.WriteLine(greet1);

            var greet2 = await client.SayHelloToAsync(person);

            Console.WriteLine(greet2);
        }