protected override void AddGenericVoidAsyncMethodCore <TRequest>( Func <TService, TRequest, CancellationToken, Task> serviceCaller, RpcServerFaultHandler faultHandler, RpcStub <TService> serviceStub, RpcOperationInfo operationInfo, ILightweightMethodBinder binder) { var serializer = operationInfo.SerializerOverride ?? serviceStub.Serializer; ValueTask <RpcResponse> HandleRequest(TRequest request, IServiceProvider?serviceProvider, LightweightCallContext context) => serviceStub.CallVoidAsyncMethod(request, serviceProvider, context, serviceCaller, faultHandler, serializer); var methodStub = new LightweightMethodStub <TRequest, RpcResponse>(operationInfo.FullName, HandleRequest, serializer, faultHandler, operationInfo.AllowInlineExecution); binder.AddMethod(methodStub); }
protected override void AddGenericVoidAsyncMethodCore <TRequest>( Func <TService, TRequest, CancellationToken, Task> serviceCaller, RpcServerFaultHandler faultHandler, RpcStub <TService> serviceStub, RpcOperationInfo operationInfo, INetGrpcBinder <TService> binder) { var serializer = serviceStub.Serializer; Task <RpcResponse> Handler(NetGrpcServiceActivator <TService> activator, TRequest request, ServerCallContext context) => serviceStub.CallVoidAsyncMethod( request, activator.ServiceProvider, new GrpcCallContext(context), serviceCaller, faultHandler, serializer).AsTask(); var methodStub = GrpcMethodDefinition.Create <TRequest, RpcResponse>( MethodType.Unary, operationInfo.FullServiceName, operationInfo.Name, serializer); binder.AddUnaryMethod(methodStub, operationInfo.Metadata, Handler); }
protected override void AddGenericVoidAsyncMethodCore <TRequest>( Func <TService, TRequest, CancellationToken, Task> serviceCaller, RpcServerFaultHandler faultHandler, RpcStub <TService> serviceStub, RpcOperationInfo operationInfo, IGrpcMethodBinder binder) { var serializer = serviceStub.Serializer; GrpcCore.UnaryServerMethod <TRequest, RpcResponse> handler = (request, context) => { using (var serviceScope = CreateServiceScope(serviceStub)) { return(serviceStub.CallVoidAsyncMethod(request, serviceScope?.ServiceProvider, new GrpcCallContext(context), serviceCaller, faultHandler, serializer).AsTask()); } }; binder.AddMethod( GrpcMethodDefinition.Create <TRequest, RpcResponse>(GrpcCore.MethodType.Unary, operationInfo.FullServiceName, operationInfo.Name, serializer), handler); }