private GrpcServiceMethodOptions GetServiceMethod(string name) { if (_resolvedServiceMethods.TryGetValue(name, out var serviceMethod) == false || serviceMethod == null) { serviceMethod = new GrpcServiceMethodOptions(name); } serviceMethod.Interceptors.InsertRange(0, _resolvedOptions.Interceptors); serviceMethod.HasInterceptors = serviceMethod.Interceptors.Count > 0; return(serviceMethod); }
/// <summary> /// Adds service method specific options to the specified <see cref="GrpcServiceOptions" />. /// </summary> /// <typeparam name="TService">The service type to configure the methods options on.</typeparam> /// <param name="serviceOptions">The <see cref="GrpcServiceOptions" /> to add the method options to.</param> /// <param name="name">The name of the method.</param> /// <param name="configure">A callback to configure the service options.</param> public static void AddMethodOptions <TService>(this GrpcServiceOptions <TService> serviceOptions, string name, Action <GrpcServiceMethodOptions> configure) where TService : class { if (serviceOptions == null) { throw new ArgumentNullException(nameof(serviceOptions)); } var serviceMethodOptions = new GrpcServiceMethodOptions(name); configure(serviceMethodOptions); serviceOptions.Methods.Add(serviceMethodOptions); }
public UnaryServerCallHandler( Method <TRequest, TResponse> method, UnaryServerMethod <TService, TRequest, TResponse> invoker, GrpcServiceMethodOptions serviceMethodOptions, GrpcServiceOptions serviceOptions, ILoggerFactory loggerFactory, IGrpcServiceActivator <TService> serviceActivator, IServiceProvider serviceProvider) : base(method, serviceOptions, loggerFactory, serviceActivator, serviceProvider) { _invoker = invoker; if (serviceMethodOptions.HasInterceptors) { var interceptorPipeline = new InterceptorPipelineBuilder <TRequest, TResponse>(serviceMethodOptions.Interceptors, ServiceProvider); _pipelineInvoker = interceptorPipeline.UnaryPipeline(ResolvedInterceptorInvoker); } }