Ejemplo n.º 1
0
        public DefaultHandlerProvider(ICommandContextFactory commandContextFactory, IEventContextFactory eventContextFactory)
        {
            this._commandContextFactory = commandContextFactory;
            this._eventContextFactory = eventContextFactory;

            this.singleHandlerDict = new Dictionary<Type, IProxyHandler>();
            this.manyHandlerDict = new Dictionary<Type, IEnumerable<IProxyHandler>>();
        }
        public CommandHostedService(
            ICommandContextFactory contextFactory)
        {
            _contextFactory = contextFactory;

            _executionRequests = Channel.CreateUnbounded <CommandContext>(
                new UnboundedChannelOptions
            {
                SingleReader = true,
                SingleWriter = false
            });
        }
Ejemplo n.º 3
0
 public LineReaderService(
     ICommandContextFactory commandContextFactory,
     ICommandExecutor commandExecutor,
     ICommandParser commandParser,
     ICommandStore commandStore,
     ILogger <LineReaderService> logger)
 {
     _commandContextFactory = commandContextFactory;
     _commandExecutor       = commandExecutor;
     _commandParser         = commandParser;
     _commandStore          = commandStore;
     _logger = logger;
 }
Ejemplo n.º 4
0
        public CommandScenario()
        {
            principal = new GenericPrincipal(new GenericIdentity("test"), new string[] { });

            event_source    = new Mock <IEventSource>();
            GeneratedEvents = new UncommittedEventStream(event_source.Object);
            uncommitted_event_stream_coordinator = new Mock <IUncommittedEventStreamCoordinator>();
            process_method_invoker         = new Mock <IProcessMethodInvoker>();
            call_context_mock              = new Mock <ICallContext>();
            execution_context_factory_mock = new Mock <IExecutionContextFactory>();
            execution_context_manager      = new ExecutionContextManager(execution_context_factory_mock.Object, call_context_mock.Object);
            command_context_factory        = new CommandContextFactory(uncommitted_event_stream_coordinator.Object, process_method_invoker.Object, execution_context_manager);
            command_context_manager        = new CommandContextManager(command_context_factory);

            command_handler_manager = new Mock <ICommandHandlerManager>();
            command_handler_manager.Setup(m => m.Handle(It.IsAny <ICommand>())).Callback((ICommand c) => command_handler.Handle((dynamic)c));

            localizer = new Mock <ILocalizer>();

            command_validators_mock = new Mock <ICommandValidators>();

            command_security_manager_mock = new Mock <ICommandSecurityManager>();
            //TODO: Allow spec'ing of Security
            command_security_manager_mock.Setup(s => s.Authorize(It.IsAny <ICommand>())).Returns(new AuthorizationResult());

            command_coordinator = new CommandCoordinator(
                command_handler_manager.Object,
                command_context_manager,
                command_security_manager_mock.Object,
                command_validators_mock.Object,
                localizer.Object,
                Mock.Of <IExceptionPublisher>(),
                Mock.Of <ILogger>());

            null_validator_mock = new Mock <ICanValidate <T> >();
            null_validator      = null_validator_mock.Object;
            input_validator     = null_validator;
            business_validator  = null_validator;

            uncommitted_event_stream_coordinator.Setup(es => es.Commit(It.IsAny <TransactionCorrelationId>(), It.IsAny <UncommittedEventStream>()))
            .Callback((TransactionCorrelationId i, UncommittedEventStream ues) => RecordGeneratedEvents(ues));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of <see cref="CommandContextManager">CommandContextManager</see>
 /// </summary>
 /// <param name="factory">A <see cref="ICommandContextFactory"/> to use for building an <see cref="ICommandContext"/></param>
 public CommandContextManager(ICommandContextFactory factory)
 {
     _factory = factory;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of <see cref="CommandContextManager">CommandContextManager</see>
 /// </summary>
 /// <param name="factory">A <see cref="ICommandContextFactory"/> to use for building an <see cref="ICommandContext"/></param>
 public ControllerActionCommandContextManager(ICommandContextFactory factory)
 {
     _factory = factory;
 }
Ejemplo n.º 7
0
 public CommandHandlerWrapper(IHandler handler, ICommandContextFactory commandContextFactory)
     : base(handler)
 {
     this.commandContextFactory = commandContextFactory;
 }
 public void UseCommandContextFactory(ICommandContextFactory factory)
 {
     _commandContextFactory = factory;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of <see cref="CommandContextManager">CommandContextManager</see>
 /// </summary>
 /// <param name="factory">A <see cref="ICommandContextFactory"/> to use for building an <see cref="ICommandContext"/></param>
 public CommandContextManager(ICommandContextFactory factory)
 {
     _factory = factory;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandContextManager"/> class.
 /// </summary>
 /// <param name="factory">A <see cref="ICommandContextFactory"/> to use for building an <see cref="ICommandContext"/>.</param>
 /// <param name="executionContextManager">The <see cref="IExecutionContextManager" />.</param>
 /// <param name="logger">The <see cref="ILogger" />.</param>
 public CommandContextManager(ICommandContextFactory factory, IExecutionContextManager executionContextManager, ILogger logger)
 {
     _factory = factory;
     _executionContextManager = executionContextManager;
     _logger = logger;
 }