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; } } }
public TResult Execute <TResult>(IAPICommand <TResult> command) { return(commandDispatcher.Dispatch <TResult>(command)); }
public void Execute(IAPICommand command) { commandDispatcher.Dispatch <object>(command); }