public void Initialize()
        {
            _handler = A.Fake <IHandlerStore>();

            _config = new MapGrpcServiceConfiguration();

            _compiler = new DispatcherCompiler(_handler, _config);
        }
Exemplo n.º 2
0
        public void Initialize()
        {
            _callContext = TestServerCallContext.Create(_guid.ToString(),
                                                        null, DateTime.Now, null, CancellationToken.None, null, null, null, null, null, null);

            _handler    = A.Fake <IHandlerStore>();
            _dispatcher = A.Fake <IDispatcher>();

            _config = new MapGrpcServiceConfiguration();

            _compiler = new DispatcherCompiler(_handler, _config);
        }
        /// <summary>
        /// Creates an implementation of <paramref name="serviceBaseType"/> and maps the implementation so it can be called.
        /// </summary>
        /// <param name="builder">The <see cref="IEndpointRouteBuilder"/> used to map the implementation of the service.</param>
        /// <param name="serviceProvider">The instance of the root <see cref="IServiceProvider"/>, required to get the registered services.</param>
        /// <param name="serviceBaseType">The base type of the service, Greeter.GreeterBase would be an example for the Greeter service that comes with the template.</param>
        /// <param name="configureService">An action used to further configure the generated service class and mapping.</param>
        /// <returns><see cref="GrpcServiceEndpointConventionBuilder"/> that can be used to customize the mapping.</returns>
        public static GrpcServiceEndpointConventionBuilder CompileAndMapGrpcServiceDispatcher(this IEndpointRouteBuilder builder, IServiceProvider serviceProvider, Type serviceBaseType, Action <IMapGrpcServiceConfigurationBuilder> configureService = null)
        {
            if (serviceBaseType == null)
            {
                throw new ArgumentNullException(nameof(serviceBaseType));
            }

            MapGrpcServiceConfiguration configuration = new MapGrpcServiceConfiguration();

            configureService?.Invoke(configuration);

            var handlerStore = serviceProvider.GetService <IHandlerStore>();

            // compile a dispatchertype
            DispatcherCompiler compiler = new DispatcherCompiler(handlerStore, configuration);
            var dispatcherType          = compiler.CompileDispatcher(serviceBaseType);

            return(MapGrpcService(builder, dispatcherType));
        }
Exemplo n.º 4
0
        public void Initialize()
        {
            _callContext = TestServerCallContext.Create(_guid.ToString(),
                                                        null, DateTime.Now, null, CancellationToken.None, null, null, null, null, null, null);

            _methodOneAttributes = new[]
            {
                new AuthorizeAttribute("my.policy.1")
                {
                    Roles = "my.role.1", AuthenticationSchemes = "my.scheme.1"
                },
                new AuthorizeAttribute("my.policy.2")
                {
                    Roles = "my.role.2", AuthenticationSchemes = "my.scheme.2"
                },
            };

            _methodTwoAttributes = new[]
            {
                new AuthorizeAttribute("my.policy.3")
                {
                    Roles = "my.role.3", AuthenticationSchemes = "my.scheme.3"
                },
                new AuthorizeAttribute("my.policy.4")
                {
                    Roles = "my.role.4", AuthenticationSchemes = "my.scheme.4"
                },
            };

            _handler    = A.Fake <IHandlerStore>();
            _dispatcher = A.Fake <IDispatcher>();

            _config = new MapGrpcServiceConfiguration();

            _compiler = new DispatcherCompiler(_handler, _config);
        }