Exemplo n.º 1
0
        public void Dispatch <T>(T command) where T : ICommand
        {
            var handler = _factory.CreateHandler <T>();

            //
            handler.Handle(command);
        }
Exemplo n.º 2
0
        public void Dispatch <T>(T command) where T : ICommand
        {
            var handler = _factory.CreateHandler <T>();

            try
            {
                //  handler.Uow.Begin();
                handler = new TransactionalCommandHandlerDecorator <T>(handler, _eventBus);// Decorate command handler
                handler.Handle(command);
                //   handler.Uow.Commit();
                //if (System.Transactions.Transaction.Current == null)
                //{
                //    _eventBus.Publish(new TransactionCommitedEvent());
                //}
            }
            catch (Exception ex)
            {
                handler.Uow.Rollback();
                throw ex;
            }
        }
Exemplo n.º 3
0
 public void Register <TCommand>(Handler <TAgg, TId, TState, TCommand> handler)
     where TCommand : ICommand <TAgg, TId, IExecutionResult>
 {
     _services.Register(c => _commandHandlerFactory.CreateHandler(handler, c));
 }
Exemplo n.º 4
0
 public async Task DispatchAsync <T>(T command, CancellationToken cancellationToken)
 {
     await _factory.CreateHandler <T>().HandleAsync(command, cancellationToken);
 }
Exemplo n.º 5
0
 public async Task Dispatch <T>(T command)
 {
     var handler = _factory.CreateHandler(command);
     await handler.Handle(command);
 }
Exemplo n.º 6
0
 private ICommandHandler <TCommand> ResolveHandler <TCommand>() where TCommand : ICommand
 {
     return((ICommandHandler <TCommand>)_commandHandlerFactory.CreateHandler(typeof(ICommandHandler <TCommand>)));
 }