public void Dispatch(ICommand<IIdentity> command)
        {
            var id = command.Id;
            var events = LoadEventsFromEventStore(id);
            var observer = GetObserver();

            var taskId = id as TaskId;
            if (taskId != null)
            {
                var state = new TaskAggregateState(events);
                var agg = new TaskAggregate(state, observer);
                agg.Execute(command);
                return;
            }

            // other aggregate types
            // ...

            throw new Exception(
                string.Format("Unexpected aggregate id type '{0}'",
                              id.GetType()));
        }
Ejemplo n.º 2
0
        public void Dispatch(ICommand <IIdentity> command)
        {
            var id       = command.Id;
            var events   = LoadEventsFromEventStore(id);
            var observer = GetObserver();

            var taskId = id as TaskId;

            if (taskId != null)
            {
                var state = new TaskAggregateState(events);
                var agg   = new TaskAggregate(state, observer);
                agg.Execute(command);
                return;
            }

            // other aggregate types
            // ...

            throw new Exception(
                      string.Format("Unexpected aggregate id type '{0}'",
                                    id.GetType()));
        }
Ejemplo n.º 3
0
 public TaskAggregate(TaskAggregateState state, Action <IEvent <IIdentity> > observer)
 {
     this.state    = state;
     this.observer = observer;
 }
 public TaskAggregate(TaskAggregateState state, Action<IEvent<IIdentity>> observer)
 {
     this.state = state;
     this.observer = observer;
 }