예제 #1
0
 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));
 }
예제 #2
0
        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));
        }