public void OnAfterExecution(CommandContext context) { OnAfterExecutionCalled = true; Assert.That(context.ExecutorResolved); Assert.That(context.ExecutorHasBeenCalled); Assert.That(context.Exception, Is.Null); }
public void OnBeforeBeforeExecutorResolving(CommandContext context) { OnBeforeExecutorResolvingCalled = true; Assert.That(!context.ExecutorResolved); Assert.That(!context.ExecutorHasBeenCalled); Assert.That(context.Exception, Is.Null); }
public virtual void Execute(ICommand command) { var context = new CommandContext(command); var interceptors = _container.ResolveAll<ICommandServiceInterceptor>().ToList(); try { interceptors.ForEach(i => i.OnBeforeBeforeExecutorResolving(context)); var executor = GetExecutorForCommand(command); if (executor == null) throw new ExecutorForCommandNotFoundException(command.GetType()); context = new CommandContext(command, CommandExecutionState.Resolved); interceptors.ForEach(i => i.OnBeforeExecution(context)); executor.Execute((dynamic) command); context = new CommandContext(command, CommandExecutionState.Called); } catch (Exception ex) { context = new CommandContext(command, CommandExecutionState.Called, ex); throw; } finally { interceptors.ForEach(i => i.OnAfterExecution(context)); } }
public void OnBeforeExecution(CommandContext context) { ValidateSet(context.TheCommandType, context.TheCommand); }
public void OnBeforeBeforeExecutorResolving(CommandContext context) { }
public void OnAfterExecution(CommandContext context) { }
public void OnAfterExecution(CommandContext context) { if (context != null && context.Exception != null) throw context.Exception; }
public void OnBeforeExecution(CommandContext context) { }
public void OnBeforeExecution(CommandContext context) { // Validate command instance Validate(context.TheCommandType, context.TheCommand); }
public void OnAfterExecution(CommandContext context) { // Do nothing }