public static async Task DependendRequestsExample(Math.IMathClient client) { var numbers = new List <Num> { new Num.Builder { Num_ = 1 }.Build(), new Num.Builder { Num_ = 2 }.Build(), new Num.Builder { Num_ = 3 }.Build() }; Num sum; using (var sumCall = client.Sum()) { await sumCall.RequestStream.WriteAll(numbers); sum = await sumCall.Result; } DivReply result = await client.DivAsync(new DivArgs.Builder { Dividend = sum.Num_, Divisor = numbers.Count }.Build()); Console.WriteLine("Avg Result: " + result); }
public static void DivExample(Math.IMathClient client) { DivReply result = client.Div(new DivArgs.Builder { Dividend = 10, Divisor = 3 }.Build()); Console.WriteLine("Div Result: " + result); }
public static async Task DivAsyncExample(Math.IMathClient client) { Task <DivReply> resultTask = client.DivAsync(new DivArgs.Builder { Dividend = 4, Divisor = 5 }.Build()); DivReply result = await resultTask; Console.WriteLine("DivAsync Result: " + result); }
public static async Task DivAsyncWithCancellationExample(Math.IMathClient stub) { Task <DivReply> resultTask = stub.DivAsync(new DivArgs.Builder { Dividend = 4, Divisor = 5 }.Build()); DivReply result = await resultTask; Console.WriteLine(result); }
public static async Task FibExample(Math.IMathClient stub) { var call = stub.Fib(new FibArgs.Builder { Limit = 5 }.Build()); List <Num> result = await call.ResponseStream.ToList(); Console.WriteLine("Fib Result: " + string.Join("|", result)); }
public static async Task FibExample(Math.IMathClient client) { using (var call = client.Fib(new FibArgs { Limit = 5 })) { List <Num> result = await call.ResponseStream.ToListAsync(); Console.WriteLine("Fib Result: " + string.Join("|", result)); } }
public static async Task DivManyExample(Math.IMathClient stub) { var divArgsList = new List <DivArgs> { new DivArgs.Builder { Dividend = 10, Divisor = 3 }.Build(), new DivArgs.Builder { Dividend = 100, Divisor = 21 }.Build(), new DivArgs.Builder { Dividend = 7, Divisor = 2 }.Build() }; var call = stub.DivMany(); await call.RequestStream.WriteAll(divArgsList); Console.WriteLine("DivMany Result: " + string.Join("|", await call.ResponseStream.ToList())); }
public static async Task SumExample(Math.IMathClient 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 call = stub.Sum(); await call.RequestStream.WriteAll(numbers); Console.WriteLine("Sum Result: " + await call.Result); }
public void Init() { GrpcEnvironment.Initialize(); server = new Server(); server.AddServiceDefinition(Math.BindService(new MathServiceImpl())); int port = server.AddListeningPort(host, Server.PickUnusedPort); server.Start(); channel = new Channel(host, port); // TODO(jtattermusch): get rid of the custom header here once we have dedicated tests // for header support. var stubConfig = new StubConfiguration((headerBuilder) => { headerBuilder.Add(new Metadata.MetadataEntry("customHeader", "abcdef")); }); client = Math.NewStub(channel, stubConfig); }
public static async Task DivManyExample(Math.IMathClient client) { var divArgsList = new List <DivArgs> { new DivArgs { Dividend = 10, Divisor = 3 }, new DivArgs { Dividend = 100, Divisor = 21 }, new DivArgs { Dividend = 7, Divisor = 2 } }; using (var call = client.DivMany()) { await call.RequestStream.WriteAllAsync(divArgsList); Console.WriteLine("DivMany Result: " + string.Join("|", await call.ResponseStream.ToListAsync())); } }
public static async Task SumExample(Math.IMathClient client) { var numbers = new List <Num> { new Num { Num_ = 1 }, new Num { Num_ = 2 }, new Num { Num_ = 3 } }; using (var call = client.Sum()) { await call.RequestStream.WriteAllAsync(numbers); Console.WriteLine("Sum Result: " + await call.ResponseAsync); } }
public static async Task DivAsyncExample(Math.IMathClient client) { DivReply result = await client.DivAsync(new DivArgs { Dividend = 4, Divisor = 5 }); Console.WriteLine("DivAsync Result: " + result); }
public void Init() { GrpcEnvironment.Initialize(); server = new Server(); server.AddServiceDefinition(Math.BindService(new MathServiceImpl())); int port = server.AddListeningPort(host, Server.PickUnusedPort); server.Start(); channel = new Channel(host + ":" + port); // TODO(jtattermusch): get rid of the custom header here once we have dedicated tests // for header support. var stubConfig = new StubConfiguration((headerBuilder) => { headerBuilder.Add(new Metadata.MetadataEntry("customHeader", "abcdef")); }); client = Math.NewStub(channel, stubConfig); }