Пример #1
0
 void ValidateEventStream(CommittedEvents eventStream)
 {
     if (!IsForThisEventSource(eventStream.EventSourceId))
     {
         throw new EventBelongsToOtherEventSource(eventStream.EventSourceId, EventSourceId);
     }
 }
Пример #2
0
 void ValidateEventStream(CommittedEvents eventStream)
 {
     if (!IsForThisEventSource(eventStream.EventSourceId))
     {
         throw new InvalidOperationException("Cannot apply an EventStream belonging to a different event source." +
                                             string.Format(@"Expected events for Id {0} but got events for Id {1}", EventSourceId, eventStream.EventSourceId));
     }
 }
Пример #3
0
        /// <inheritdoc/>
        public virtual void ReApply(CommittedEvents eventStream)
        {
            ValidateEventStream(eventStream);

            foreach (var committedEvent in eventStream)
            {
                InvokeOnMethod(committedEvent.Event);
                Version = committedEvent.Version.ToEventSourceVersion();
            }

            Version = Version.NextCommit();
        }