void ValidateEventStream(CommittedEvents eventStream) { if (!IsForThisEventSource(eventStream.EventSourceId)) { throw new EventBelongsToOtherEventSource(eventStream.EventSourceId, EventSourceId); } }
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)); } }
/// <inheritdoc/> public virtual void ReApply(CommittedEvents eventStream) { ValidateEventStream(eventStream); foreach (var committedEvent in eventStream) { InvokeOnMethod(committedEvent.Event); Version = committedEvent.Version.ToEventSourceVersion(); } Version = Version.NextCommit(); }