示例#1
0
        public static void SumExample(MathGrpc.IMathServiceClient stub)
        {
            List <Num> numbers = new List <Num>
            {
                new Num.Builder {
                    Num_ = 1
                }.Build(),
                new Num.Builder {
                    Num_ = 2
                }.Build(),
                new Num.Builder {
                    Num_ = 3
                }.Build()
            };

            var res = stub.Sum();

            foreach (var num in numbers)
            {
                res.Inputs.OnNext(num);
            }
            res.Inputs.OnCompleted();

            Console.WriteLine("Sum Result: " + res.Task.Result);
        }
示例#2
0
        public void Sum()
        {
            var clientStreamingResult = client.Sum();
            var numList = new List <long> {
                10, 20, 30
            }.ConvertAll(
                n => Num.CreateBuilder().SetNum_(n).Build());

            numList.Subscribe(clientStreamingResult.Inputs);

            Assert.AreEqual(60, clientStreamingResult.Task.Result.Num_);
        }
示例#3
0
        public void Sum()
        {
            var res = client.Sum();

            foreach (var num in new long[] { 10, 20, 30 })
            {
                res.Inputs.OnNext(Num.CreateBuilder().SetNum_(num).Build());
            }
            res.Inputs.OnCompleted();

            Assert.AreEqual(60, res.Task.Result.Num_);
        }
示例#4
0
        public static async Task SumExample(MathGrpc.IMathServiceClient stub)
        {
            var numbers = new List <Num>
            {
                new Num.Builder {
                    Num_ = 1
                }.Build(),
                new Num.Builder {
                    Num_ = 2
                }.Build(),
                new Num.Builder {
                    Num_ = 3
                }.Build()
            };

            var clientStreamingResult = stub.Sum();

            numbers.Subscribe(clientStreamingResult.Inputs);
            Console.WriteLine("Sum Result: " + await clientStreamingResult.Task);
        }
示例#5
0
        public static async Task DependendRequestsExample(MathGrpc.IMathServiceClient stub)
        {
            var numbers = new List <Num>
            {
                new Num.Builder {
                    Num_ = 1
                }.Build(),
                new Num.Builder {
                    Num_ = 2
                }.Build(),
                new Num.Builder {
                    Num_ = 3
                }.Build()
            };

            var clientStreamingResult = stub.Sum();

            numbers.Subscribe(clientStreamingResult.Inputs);
            Num sum = await clientStreamingResult.Task;

            DivReply result = await stub.DivAsync(new DivArgs.Builder { Dividend = sum.Num_, Divisor = numbers.Count }.Build());

            Console.WriteLine("Avg Result: " + result);
        }