예제 #1
0
        public INeedAQueryContext Handlers(IQueryHandlerRegistry handlerRegistry, Func <Type, IQueryHandler> handlerFactory,
                                           Action <Type> decoratorRegistry, Func <Type, IQueryHandlerDecorator> decoratorFactory)
        {
            if (handlerRegistry == null)
            {
                throw new ArgumentNullException(nameof(handlerRegistry));
            }
            if (handlerFactory == null)
            {
                throw new ArgumentNullException(nameof(handlerFactory));
            }
            if (decoratorRegistry == null)
            {
                throw new ArgumentNullException(nameof(decoratorRegistry));
            }
            if (decoratorFactory == null)
            {
                throw new ArgumentNullException(nameof(decoratorFactory));
            }

            _handlerConfiguration = new HandlerConfiguration(
                handlerRegistry,
                new FactoryFuncWrapper(handlerFactory),
                new RegistryActionWrapper(decoratorRegistry),
                new FactoryFuncWrapper(decoratorFactory));

            return(this);
        }
예제 #2
0
 public QueryProcessor(
     IQueryHandlerRegistry registry,
     IQueryHandlerFactory factory)
 {
     _registry = registry;
     _factory  = factory;
 }
예제 #3
0
        public QueryProcessor(IHandlerConfiguration handlerConfiguration, IPolicyRegistry policyRegistry, IRequestContextFactory requestContextFactory)
        {
            if (handlerConfiguration == null)
            {
                throw new ArgumentNullException(nameof(handlerConfiguration));
            }
            if (policyRegistry == null)
            {
                throw new ArgumentNullException(nameof(policyRegistry));
            }
            if (requestContextFactory == null)
            {
                throw new ArgumentNullException(nameof(requestContextFactory));
            }

            if (handlerConfiguration.HandlerRegistry == null)
            {
                throw new ArgumentException($"{nameof(handlerConfiguration.HandlerRegistry)} must not be null", nameof(handlerConfiguration));
            }
            if (handlerConfiguration.HandlerFactory == null)
            {
                throw new ArgumentException($"{nameof(handlerConfiguration.HandlerFactory)} must not be null", nameof(handlerConfiguration));
            }
            if (handlerConfiguration.DecoratorFactory == null)
            {
                throw new ArgumentException($"{nameof(handlerConfiguration.DecoratorFactory)} must not be null", nameof(handlerConfiguration));
            }

            _handlerRegistry       = handlerConfiguration.HandlerRegistry;
            _handlerFactory        = handlerConfiguration.HandlerFactory;
            _decoratorFactory      = handlerConfiguration.DecoratorFactory;
            _policyRegistry        = policyRegistry;
            _requestContextFactory = requestContextFactory;
        }
예제 #4
0
        public void BootstrapQueries(
            IQueryHandlerRegistry queryHandlerRegistry,
            IEventBus eventBus,
            IQueryDispatcher queryDispatcher)
        {
            var personView = new PersonView();

            queryHandlerRegistry.SetHandler <GetPersonIdByNameQuery, object>(personView.Execute);
            queryHandlerRegistry.SetHandler <GetPeopleNamesQuery, IEnumerable <PersonName> >(personView.Execute);
            eventBus.RegisterListener <PersonCreatedEvent>(personView.Update);

            var journeysByPassengerThenMonthThenDayView = new JourneysByPassengerThenMonthThenDayView();

            queryHandlerRegistry.SetHandler <GetJourneysByPassengerThenMonthThenDayQuery, IEnumerable <Fact> >(journeysByPassengerThenMonthThenDayView.Execute);
            eventBus.RegisterListener <JourneyCreatedEvent>(journeysByPassengerThenMonthThenDayView.Update);
            eventBus.RegisterListener <LiftAddedEvent>(journeysByPassengerThenMonthThenDayView.Update);

            var journeyView = new JourneyView();

            queryHandlerRegistry.SetHandler <GetJourneysInPeriodQuery, IEnumerable <Journey> >(journeyView.Execute);
            eventBus.RegisterListener <JourneyCreatedEvent>(journeyView.Update);
            eventBus.RegisterListener <LiftAddedEvent>(journeyView.Update);

            var passengerLiftsCostCalculator = new PassengerLiftCostCalculator(queryDispatcher);

            queryHandlerRegistry.SetHandler <GetCostOfPassengerLiftsInPeriodQuery, PassengerLiftsCost>(passengerLiftsCostCalculator.Execute);
        }
예제 #5
0
        public INeedAQueryContext Handlers(IQueryHandlerRegistry handlerRegistry, IQueryHandlerFactory handlerFactory,
                                           IQueryHandlerDecoratorRegistry decoratorRegistry, IQueryHandlerDecoratorFactory decoratorFactory)
        {
            if (handlerRegistry == null)
            {
                throw new ArgumentNullException(nameof(handlerRegistry));
            }
            if (handlerFactory == null)
            {
                throw new ArgumentNullException(nameof(handlerFactory));
            }
            if (decoratorRegistry == null)
            {
                throw new ArgumentNullException(nameof(decoratorRegistry));
            }
            if (decoratorFactory == null)
            {
                throw new ArgumentNullException(nameof(decoratorFactory));
            }

            _handlerConfiguration = new HandlerConfiguration(
                handlerRegistry,
                handlerFactory,
                decoratorRegistry,
                decoratorFactory);

            return(this);
        }
예제 #6
0
        public FallbackPolicyTests()
        {
            _handlerFactory   = new Mock <IQueryHandlerFactory>();
            _decoratorFactory = new Mock <IQueryHandlerDecoratorFactory>();
            _handlerRegistry  = new QueryHandlerRegistry();

            var handlerConfiguration = new HandlerConfiguration(_handlerRegistry, _handlerFactory.Object, _decoratorFactory.Object);

            _queryProcessor = new QueryProcessor(handlerConfiguration, new InMemoryQueryContextFactory());
        }
예제 #7
0
 public HandlerConfiguration(
     IQueryHandlerRegistry handlerRegistry,
     IQueryHandlerFactory handlerFactory,
     IQueryHandlerDecoratorRegistry decoratorRegistry,
     IQueryHandlerDecoratorFactory decoratorFactory)
 {
     HandlerRegistry   = handlerRegistry ?? throw new ArgumentNullException(nameof(handlerRegistry));
     HandlerFactory    = handlerFactory ?? throw new ArgumentNullException(nameof(handlerFactory));
     DecoratorRegistry = decoratorRegistry ?? throw new ArgumentNullException(nameof(decoratorRegistry));
     DecoratorFactory  = decoratorFactory ?? throw new ArgumentNullException(nameof(decoratorFactory));
 }
예제 #8
0
 public Bootstrapper(
     IEventBus eventBus,
     ICommandDispatcher commandDispatcher,
     ICommandHandlerRegistry commandHandlerRegistry,
     IQueryDispatcher queryDispatcher,
     IQueryHandlerRegistry queryHandlerRegistry,
     IIdFactory idFactory)
 {
     _eventBus               = eventBus;
     _commandDispatcher      = commandDispatcher;
     _commandHandlerRegistry = commandHandlerRegistry;
     _queryDispatcher        = queryDispatcher;
     _queryHandlerRegistry   = queryHandlerRegistry;
     _idFactory              = idFactory;
 }
예제 #9
0
        public QueryProcessor(
            IHandlerConfiguration handlerConfiguration,
            IQueryContextFactory queryContextFactory,
            IReadOnlyDictionary <string, object> contextBagData = null)
        {
            if (handlerConfiguration == null)
            {
                throw new ArgumentNullException(nameof(handlerConfiguration));
            }

            _handlerRegistry  = handlerConfiguration.HandlerRegistry ?? throw new ArgumentException($"{nameof(handlerConfiguration.HandlerRegistry)} must not be null", nameof(handlerConfiguration));
            _handlerFactory   = handlerConfiguration.HandlerFactory ?? throw new ArgumentException($"{nameof(handlerConfiguration.HandlerFactory)} must not be null", nameof(handlerConfiguration));
            _decoratorFactory = handlerConfiguration.DecoratorFactory ?? throw new ArgumentException($"{nameof(handlerConfiguration.DecoratorFactory)} must not be null", nameof(handlerConfiguration));

            _queryContextFactory = queryContextFactory ?? throw new ArgumentNullException(nameof(queryContextFactory));
            _contextBagData      = contextBagData ?? new Dictionary <string, object>();
        }
예제 #10
0
        public INeedPolicies Handlers(IQueryHandlerRegistry handlerRegistry, Func <Type, object> handlerFactory, Func <Type, object> decoratorFactory)
        {
            if (handlerRegistry == null)
            {
                throw new ArgumentNullException(nameof(handlerRegistry));
            }
            if (handlerFactory == null)
            {
                throw new ArgumentNullException(nameof(handlerFactory));
            }
            if (decoratorFactory == null)
            {
                throw new ArgumentNullException(nameof(decoratorFactory));
            }

            _handlerConfiguration = new HandlerConfiguration(handlerRegistry, new FactoryFuncWrapper(handlerFactory), new FactoryFuncWrapper(decoratorFactory));
            return(this);
        }
예제 #11
0
 public AspNetDependencyInjectionHandlerConfigurationBuilder(IServiceCollection services)
 {
     _services        = services;
     _handlerRegistry = new QueryHandlerRegistry();
 }
예제 #12
0
 public QueryProcessor(IServiceProvider serviceProvider, IQueryHandlerRegistry queryHandlerRegistry)
 {
     _serviceProvider = serviceProvider;
     _registry        = queryHandlerRegistry;
 }
예제 #13
0
 public QueryDispatcher(IQueryHandlerRegistry queryRegistry)
 {
     _queryRegistry = queryRegistry;
 }
예제 #14
0
 public SimpleInjectorHandlerConfigurationBuilder(Container container)
 {
     _container       = container;
     _handlerRegistry = new QueryHandlerRegistry();
 }
예제 #15
0
 public HandlerSettings(Container container, IQueryHandlerRegistry handlerRegistry)
 {
     _container       = container;
     _handlerRegistry = handlerRegistry;
 }
예제 #16
0
 public PipelineBuilder(IQueryHandlerRegistry handlerRegistry, IQueryHandlerFactory handlerFactory, IQueryHandlerDecoratorFactory decoratorFactory)
 {
     _handlerRegistry  = handlerRegistry;
     _handlerFactory   = handlerFactory;
     _decoratorFactory = decoratorFactory;
 }
 public HandlerConfiguration(IQueryHandlerRegistry handlerRegistry, SimpleInjectorHandlerFactory factory)
 {
     HandlerRegistry  = handlerRegistry;
     HandlerFactory   = factory;
     DecoratorFactory = factory;
 }
예제 #18
0
 public AspNetDependencyInjectionHandlerConfiguration(IQueryHandlerRegistry handlerRegistry, AspNetDependencyInjectionHandlerFactory factory)
 {
     HandlerRegistry  = handlerRegistry;
     HandlerFactory   = factory;
     DecoratorFactory = factory;
 }