Exemplo n.º 1
0
        public TResult Dispatch <TResult>(IAPICommand command)
        {
            var sw             = Stopwatch.StartNew();
            var commandContext = new CommandContext();

            commandContext.CurrentCommand = command;
            using (var childContainer = iocContainer.Clone())
            {
                childContainer.Register(commandContext);
                try
                {
                    OnDispatching(commandContext);
                    var handler = handlers.FindHandler(command.GetType());
                    var result  = (TResult)handler.Execute(ResolveParameters(handler, command, childContainer));
                    OnDispatched(commandContext);
                    // TODO: logging and other instrumentation
                    sw.Stop();
                    return(result);
                }
                catch (Exception e)
                {
                    OnDispatched(commandContext, e);
                    sw.Stop();
                    // TODO: logging
                    throw;
                }
            }
        }
Exemplo n.º 2
0
 public TResult Execute <TResult>(IAPICommand <TResult> command)
 {
     return(commandDispatcher.Dispatch <TResult>(command));
 }
Exemplo n.º 3
0
 public void Execute(IAPICommand command)
 {
     commandDispatcher.Dispatch <object>(command);
 }