Exemplo n.º 1
0
        static DivReply DivInternal(DivArgs args)
        {
            long quotient  = args.Dividend / args.Divisor;
            long remainder = args.Dividend % args.Divisor;

            return(new DivReply {
                Quotient = quotient, Remainder = remainder
            });
        }
Exemplo n.º 2
0
        static DivReply DivInternal(DivArgs args)
        {
            if (args.Divisor == 0)
            {
                // One can finish the RPC with non-ok status by throwing RpcException instance.
                // Alternatively, resulting status can be set using ServerCallContext.Status
                throw new RpcException(new Status(StatusCode.InvalidArgument, "Division by zero"));
            }

            long quotient  = args.Dividend / args.Divisor;
            long remainder = args.Dividend % args.Divisor;

            return(new DivReply {
                Quotient = quotient, Remainder = remainder
            });
        }
Exemplo n.º 3
0
 public override Task <DivReply> Div(DivArgs request, ServerCallContext context)
 {
     return(Task.FromResult(DivInternal(request)));
 }