This is the current in-memory "state" half of our A+ES implementation. We split the Aggregates and Event Sourcing (A+ES) implementation into two distinct classes: - one for state (AggregateNameState), - and one for behavior (AggregateName), with the state object (this class) being held by the behavioral object (the Aggregate). The two objects collaborate exclusively through the Aggregate's Apply() method. This ensures that an Aggregate's state is changed only by means of Events. This AggregateState class typically exists for very short periods at a time (likely milliseconds) when the Aggregate is loaded from Event Stream history and the Events are replayed through this state class to derive current Aggregate state. This current in-memory state ensures that Aggregate behaviors (methods) with multiple steps, have up-to-date state to operate on for each subsequent step. When changes are made to an Aggregate, and the results are persisted back to the Event Stream by the ApplicationService, the system drops all references to this state class instance and it is garbage collected.
Наследование: ITrustedSystemState
Пример #1
0
        public static TrustedSystemState BuildStateFromEventHistory(IEnumerable <Event> events)
        {
            var aggState = new TrustedSystemState();

            foreach (var eventThatHappened in events)
            {
                aggState.MakeStateRealize((ITrustedSystemEvent)eventThatHappened);
            }
            return(aggState);
        }
 public TrustedSystemAggregate(TrustedSystemState aggStateBeforeChanges)
 {
     _aggState = aggStateBeforeChanges;
 }
Пример #3
0
        public static TrustedSystemState BuildStateFromEventHistory(IEnumerable<Event> events)
        {
            var aggState = new TrustedSystemState();

            foreach (var eventThatHappened in events)
            {
                aggState.MakeStateRealize((ITrustedSystemEvent) eventThatHappened);
            }
            return aggState;
        }
Пример #4
0
 public TrustedSystemAggregate(TrustedSystemState aggStateBeforeChanges)
 {
     _aggState = aggStateBeforeChanges;
 }