示例#1
0
        void AddServerStreamingMethod <TRequest, TResponse>(ServiceMethodProviderContext <TService> context, string serviceName, MethodInfo method)
            where TRequest : class
            where TResponse : class
        {
            var serviceMethodAttribute = method.GetCustomAttribute <GrpcMethodAttribute>();

            var serverStreamingMethod = new Method <TRequest, TResponse>(
                MethodType.ServerStreaming,
                serviceName,
                serviceMethodAttribute?.Name ?? method.Name,
                CreateRequestMarshaller <TRequest>(
                    serviceMethodAttribute?.RequestMarshallerType ?? FindRequestMarshaller <TRequest>(method)),
                CreateResponseMarshaller <TResponse>(
                    serviceMethodAttribute?.ResponseMarshallerType ?? FindResponseMarshaller <TResponse>(method)));

            context.AddServerStreamingMethod(
                serverStreamingMethod,
                Array.Empty <object>(),
                _serverStreamingSeverMethodBuilder.Build <TRequest, TResponse>(method),
                options =>
            {
                foreach (var interceptor in FindInterceptors(method))
                {
                    options.Interceptors.Add(interceptor.InterceptorType, interceptor.Args);
                }
            });
        }
 public override void AddMethod <TRequest, TResponse>(Method <TRequest, TResponse> method,
                                                      ServerStreamingServerMethod <TRequest, TResponse> handler)
 {
     m_context.AddServerStreamingMethod(method, Array.Empty <object>(),
                                        (service, request, stream, context) => handler(request, stream, context));
     m_logger.Log(LogLevel.Information, "RPC service being provided by {0}: {1}", typeof(TService),
                  method.Name);
 }
        public override void AddMethod <TRequest, TResponse>(Method <TRequest, TResponse> method, ServerStreamingServerMethod <TRequest, TResponse> handler)
        {
            var(invoker, metadata) = CreateModelCore <ServerStreamingServerMethod <TService, TRequest, TResponse> >(
                method.Name,
                new[] { typeof(TRequest), typeof(IServerStreamWriter <TResponse>), typeof(ServerCallContext) });

            _context.AddServerStreamingMethod <TRequest, TResponse>(method, metadata, invoker);
        }
示例#4
0
        public void AddServerStreamingMethod <TRequest, TResponse>(
            Method <TRequest, TResponse> method,
            IList <object> metadata,
            Func <TService, TRequest, IServerStreamWriter <TResponse>, ServerCallContext, Task> handler)
            where TRequest : class
            where TResponse : class
        {
            var invoker = handler.Method.CreateDelegate <ServerStreamingServerMethod <TService, TRequest, TResponse> >(handler.Target);

            _context.AddServerStreamingMethod(method, metadata, invoker);
        }
 public override void AddMethod <TRequest, TResponse>(Method <TRequest, TResponse> method, ServerStreamingServerMethod <TRequest, TResponse> handler)
 {
     var(invoker, metadata) = CreateModelCore <ServerStreamingServerMethod <TService, TRequest, TResponse> >(
         method.Name,
         new[] { typeof(TRequest), typeof(IServerStreamWriter <TResponse>), typeof(ServerCallContext) });
     if (_isIGrpcService)
     {
         _context.AddServerStreamingMethod <TRequest, TResponse>(method, metadata, invoker);
     }
     AddMetaMethod((new MetaMethodModel
     {
         FullName = method.FullName,
         RequestType = typeof(TRequest),
         ResponseType = typeof(TResponse),
         ServiceType = typeof(TService),
         Handler = invoker
     }));
 }
 public override void AddMethod <TRequest, TResponse>(Method <TRequest, TResponse> method, ServerStreamingServerMethod <TRequest, TResponse> handler)
 {
     _context.AddServerStreamingMethod(method, Array.Empty <object>(), (_, request, stream, context) => handler(request, stream, context));
 }
示例#7
0
 public override void AddMethod <TRequest, TResponse>(Method <TRequest, TResponse> method, ServerStreamingServerMethod <TRequest, TResponse> handler)
 {
     var(invoker, metadata) = CreateModelCore <ServerStreamingServerMethod <TService, TRequest, TResponse> >(method.Name);
     _context.AddServerStreamingMethod <TRequest, TResponse>(method, metadata, invoker);
 }