public AggregateInstance(AggregateModel model, object instance) { Model = model; Object = instance; Factory = new CommandHandlerInstance(this, model.FactoryHandler); CommandHandlers = model.CommandHandlers.Select(c => new CommandHandlerInstance(this, c)); EventHandlers = model.EventHandlers.Select(c => new EventHandlerInstance(this, c)); }
public CommandExecutionResult Execute(CommandInstance cmd) { CommandHandlerInstance handler = null; if (Factory.Handles(cmd)) { handler = Factory; } else { handler = CommandHandlers.Single(c => c.Handles(cmd)); } return(handler.Execute(cmd)); }