public void Execute <TCommand>(TCommand command) where TCommand : IBaseCommand
        {
            IBaseCommandHandler <TCommand> handler = IoC.Container.Resolve <IBaseCommandHandler <TCommand> >();

            if (handler == null)
            {
                throw new CommandHandlerNotFound <TCommand>();
            }
            handler.Handle(command);
        }
Exemplo n.º 2
0
        public TResult Dispatch <T, TResult>(T command) where T : Command
        {
            IBaseCommandHandler <T, TResult> handler = null;

            handler = (IBaseCommandHandler <T, TResult>)services.GetService((typeof(AuthorizeCommandHandlerDecorator <T, TResult>)));
            //            handler = (IBaseCommandHandler<T, TResult>)services.GetService((typeof(LoggingHandlerDecorator<T, TResult>)));
            var logManagement = (ILogManagement)services.GetService(typeof(ILogManagement));

            handler = new CatchErrorCommandHandlerDecorator <T, TResult>(new LoggingHandlerDecorator <T, TResult>(handler, logManagement));
            return(handler.Handle(command));
        }
Exemplo n.º 3
0
 public CatchErrorCommandHandlerDecorator(IBaseCommandHandler <T, TResult> next)
 {
     _next = next;
 }
 public LoggingHandlerDecorator(IBaseCommandHandler <T, TResult> next, ILogManagement log)
 {
     _log  = log;
     _next = next;
 }
Exemplo n.º 5
0
 public AuthorizeCommandHandlerDecorator(IBaseCommandHandler <T, TResult> next)
 {
     _next = next;
 }