/// <summary> /// Initializes a new instance of the <see cref="CommittedAggregateEvents"/> class. /// </summary> /// <param name="eventSource">The <see cref="EventSourceId"/> that the Events were applied to.</param> /// <param name="aggregateRoot">The <see cref="Type"/> of the Aggregate Root that applied the Events to the Event Source.</param> /// <param name="events">The <see cref="CommittedAggregateEvent">events</see>.</param> public CommittedAggregateEvents(EventSourceId eventSource, Type aggregateRoot, IReadOnlyList <CommittedAggregateEvent> events) { EventSource = eventSource; AggregateRoot = aggregateRoot; for (var i = 0; i < events.Count; i++) { if (i == 0) { _nextAggregateRootVersion = events[0].AggregateRootVersion; } var @event = events[i]; ThrowIfEventIsNull(@event); ThrowIfEventWasAppliedToOtherEventSource(@event); ThrowIfEventWasAppliedByOtherAggregateRoot(@event); ThrowIfAggreggateRootVersionIsOutOfOrder(@event); if (i > 0) { ThrowIfEventLogVersionIsOutOfOrder(@event, events[i - 1]); } _nextAggregateRootVersion++; } _events = new NullFreeList <CommittedAggregateEvent>(events); }
/// <summary> /// Initializes a new instance of the <see cref="AggregateRoot"/> class. /// </summary> /// <param name="eventSourceId">The <see cref="Events.EventSourceId"/> that the Aggregate Root will apply events on.</param> protected AggregateRoot(EventSourceId eventSourceId) { EventSourceId = eventSourceId; Version = AggregateRootVersion.Initial; _ruleSetEvaluations = new List <RuleSetEvaluation>(); _brokenRules = new List <BrokenRule>(); _uncommittedEvents = new NullFreeList <IEvent>(); }
/// <summary> /// Initializes a new instance of the <see cref="CommittedEvents"/> class. /// </summary> /// <param name="events">The <see cref="CommittedEvent">events</see>.</param> public CommittedEvents(IReadOnlyList <CommittedEvent> events) { for (var i = 0; i < events.Count; i++) { var @event = events[i]; ThrowIfEventIsNull(@event); if (i > 0) { ThrowIfEventLogVersionIsOutOfOrder(@event, events[i - 1]); } } _events = new NullFreeList <CommittedEvent>(events); }
/// <summary> /// Initializes a new instance of the <see cref="EventSequence{T}"/> class. /// </summary> /// <param name="events">IReadOnlyList of events.</param> protected EventSequence(IReadOnlyList <TEvent> events) { events.ForEach(ThrowIfEventIsNull); Events = new NullFreeList <TEvent>(events); }