public void Dispatch <T>(T command) where T : ICommand { var handler = _factory.CreateHandler <T>(); // handler.Handle(command); }
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; } }
public void Register <TCommand>(Handler <TAgg, TId, TState, TCommand> handler) where TCommand : ICommand <TAgg, TId, IExecutionResult> { _services.Register(c => _commandHandlerFactory.CreateHandler(handler, c)); }
public async Task DispatchAsync <T>(T command, CancellationToken cancellationToken) { await _factory.CreateHandler <T>().HandleAsync(command, cancellationToken); }
public async Task Dispatch <T>(T command) { var handler = _factory.CreateHandler(command); await handler.Handle(command); }
private ICommandHandler <TCommand> ResolveHandler <TCommand>() where TCommand : ICommand { return((ICommandHandler <TCommand>)_commandHandlerFactory.CreateHandler(typeof(ICommandHandler <TCommand>))); }