Exemplo n.º 1
0
 protected abstract void AddGenericVoidBlockingMethodCore <TRequest>(
     Action <TService, TRequest, CancellationToken> serviceCaller,
     RpcServerFaultHandler faultHandler,
     RpcStub <TService> serviceStub,
     RpcOperationInfo operationInfo,
     TMethodBinder binder)
     where TRequest : class, IObjectRequest;
Exemplo n.º 2
0
 protected abstract void AddGenericBlockingMethodCore <TRequest, TReturn, TResponseReturn>(
     Func <TService, TRequest, CancellationToken, TReturn> serviceCaller,
     Func <TReturn, TResponseReturn>?responseConverter,
     RpcServerFaultHandler faultHandler,
     RpcStub <TService> serviceStub,
     RpcOperationInfo operationInfo,
     TMethodBinder binder)
     where TRequest : class, IObjectRequest;
Exemplo n.º 3
0
            where TResponseReturn : class;  // Needs to be class due to gRPC restriction

        protected abstract void AddCallbackMethodCore <TRequest, TReturn, TResponseReturn>(
            Func <TService, TRequest, Action <TReturn>, CancellationToken, Task> serviceCaller,
            Func <TReturn, TResponseReturn>?responseConverter,
            RpcServerFaultHandler faultHandler,
            RpcStub <TService> serviceStub,
            RpcOperationInfo operationInfo,
            TMethodBinder binder)
            where TRequest : class, IObjectRequest
            where TResponseReturn : class;  // Needs to be class due to gRPC constraint
Exemplo n.º 4
0
 protected abstract void AddServerStreamingMethodCore <TRequest, TReturn, TResponseReturn>(
     Func <TService, TRequest, CancellationToken, IAsyncEnumerable <TReturn> > serviceCaller,
     Func <TReturn, TResponseReturn>?responseConverter,
     RpcServerFaultHandler faultHandler,
     RpcStub <TService> serviceStub,
     RpcOperationInfo operationInfo,
     TMethodBinder binder)
     where TRequest : class, IObjectRequest
     where TResponseReturn : class;  // Needs to be class due to gRPC restriction
Exemplo n.º 5
0
        protected void AddGenericServerStreamingMethod <TRequest, TReturn, TResponseReturn>(RpcStub <TService> serviceStub, RpcOperationInfo opInfo, TMethodBinder binder)
            where TRequest : class, IObjectRequest
            where TResponseReturn : class  // Needs to be class due to gRPC constraint
        {
            if (opInfo is null)
            {
                throw new ArgumentNullException(nameof(opInfo));
            }

            Func <TReturn, TResponseReturn>?responseCreator = GetResponseCreator <TReturn, TResponseReturn>(opInfo);
            RpcServerFaultHandler           faultHandler    = this.CreateFaultHandler(opInfo);

            var serviceCaller = GenerateServerStreamingMethodHandler <TRequest, TReturn>(opInfo);

            this.AddServerStreamingMethodCore(serviceCaller, responseCreator, faultHandler, serviceStub, opInfo, binder);
        }
Exemplo n.º 6
0
        protected RpcServiceStubBuilder(RpcServiceInfo serviceInfo, RpcServiceOptions <TService>?options)
        {
            this.ServiceInfo = serviceInfo ?? throw new ArgumentNullException(nameof(serviceInfo));

            this.Options = options;

            var converterAttributes = serviceInfo.Type.GetCustomAttributes <RpcFaultConverterAttribute>();
            var exceptionConverters = RetrieveServerExceptionConverters(converterAttributes);

            var faultAttributes = serviceInfo.Type.GetCustomAttributes <RpcFaultAttribute>();
            var mappings        = GetFaultToDetailsMapping(faultAttributes);

            if (exceptionConverters.Count > 0 || mappings.Count > 0)
            {
                this.FaultHandler = new RpcServerFaultHandler(null, exceptionConverters, mappings);
            }
            else
            {
                this.FaultHandler = RpcServerFaultHandler.Default;
            }
        }
Exemplo n.º 7
0
        protected void AddGenericBlockingMethod <TRequest, TReturn, TResponseReturn>(RpcStub <TService> serviceStub, RpcOperationInfo opInfo, TMethodBinder binder)
            where TRequest : class, IObjectRequest
        {
            if (opInfo is null)
            {
                throw new ArgumentNullException(nameof(opInfo));
            }

            Func <TReturn, TResponseReturn>?responseCreator = GetResponseCreator <TReturn, TResponseReturn>(opInfo);
            RpcServerFaultHandler           faultHandler    = this.CreateFaultHandler(opInfo);

            if (opInfo.IsAsync)
            {
                var serviceCaller = GenerateUnaryMethodHandler <TRequest, TReturn>(opInfo);
                this.AddGenericAsyncMethodCore(serviceCaller, responseCreator, faultHandler, serviceStub, opInfo, binder);
            }
            else
            {
                var serviceCaller = GenerateBlockingUnaryMethodHandler <TRequest, TReturn>(opInfo);
                this.AddGenericBlockingMethodCore(serviceCaller, responseCreator, faultHandler, serviceStub, opInfo, binder);
            }
        }