/// <summary>
 /// Initializes a new instance of the <see cref="UncommittedAggregateEvents"/> class.
 /// </summary>
 /// <param name="eventSource">The <see cref="EventSourceId"/> that the Events were applied to.</param>
 /// <param name="aggregateRoot">The <see cref="Artifact"/> representing the type of the Aggregate Root that applied the Event to the Event Source.</param>
 /// <param name="expectedAggregateRootVersion">The <see cref="AggregateRootVersion"/> of the Aggregate Root that was used to apply the rules that resulted in the Events.</param>
 /// <param name="events">The <see cref="UncommittedEvent">events</see>.</param>
 public UncommittedAggregateEvents(EventSourceId eventSource, Artifact aggregateRoot, AggregateRootVersion expectedAggregateRootVersion, IReadOnlyList <UncommittedEvent> events)
     : base(events)
 {
     EventSource   = eventSource;
     AggregateRoot = aggregateRoot;
     ExpectedAggregateRootVersion = expectedAggregateRootVersion;
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommittedAggregateEvent"/> class.
 /// </summary>
 /// <param name="aggregateRoot">The aggregate root <see cref="Artifact" />.</param>
 /// <param name="aggregateRootVersion">The version of the aggregate root that applied the Event.</param>
 /// <param name="eventLogSequenceNumber">The version of the Event Log the Event was committed to.</param>
 /// <param name="occurred">The <see cref="DateTimeOffset" /> when the Event was committed to the Event Store.</param>
 /// <param name="eventSource">The Event Source that the Event was applied to.</param>
 /// <param name="executionContext">The <see cref="ExecutionContext" />.</param>
 /// <param name="type">The <see cref="Artifact"/> representing the type of the Event.</param>
 /// <param name="isPublic">Whether this Event is public.</param>
 /// <param name="content">The content of the Event represented as a JSON-encoded <see cref="string"/>.</param>
 public CommittedAggregateEvent(
     Artifact aggregateRoot,
     AggregateRootVersion aggregateRootVersion,
     EventLogSequenceNumber eventLogSequenceNumber,
     DateTimeOffset occurred,
     EventSourceId eventSource,
     ExecutionContext executionContext,
     Artifact type,
     bool isPublic,
     string content)
     : base(eventLogSequenceNumber, occurred, eventSource, executionContext, type, isPublic, content)
 {
     AggregateRoot        = aggregateRoot;
     AggregateRootVersion = aggregateRootVersion;
 }
 /// <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="ArtifactId"/> representing the type of the Aggregate Root that applied the Event to the Event Source.</param>
 /// <param name="events">The <see cref="CommittedAggregateEvent">events</see>.</param>
 public CommittedAggregateEvents(EventSourceId eventSource, ArtifactId aggregateRoot, IReadOnlyList <CommittedAggregateEvent> events)
     : base(events)
 {
     EventSource   = eventSource;
     AggregateRoot = aggregateRoot;
     for (var i = 0; i < events.Count; i++)
     {
         if (i == 0)
         {
             _currentCheckedVersion = events[0].AggregateRootVersion;
         }
         var @event = events[i];
         ThrowIfEventWasAppliedToOtherEventSource(@event);
         ThrowIfEventWasAppliedByOtherAggregateRoot(@event);
         ThrowIfAggreggateRootVersionIsOutOfOrder(@event);
         _currentCheckedVersion++;
     }
 }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MissingEventsForExpectedAggregateRootVersion"/> class.
 /// </summary>
 /// <param name="expectedVersion">The expected <see cref="AggregateRootVersion"/>.</param>
 /// <param name="actualVersion">The actual <see cref="AggregateRootVersion"/> produced by the given events.</param>
 public MissingEventsForExpectedAggregateRootVersion(AggregateRootVersion expectedVersion, AggregateRootVersion actualVersion)
     : base($"Events are missing for aggregate root. Expected version '{expectedVersion}', but provided events resulted in '{actualVersion}'.")
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AggregateRootConcurrencyConflict"/> class.
 /// </summary>
 /// <param name="currentVersion">The current version before commit.</param>
 /// <param name="commitVersion">The version of the commit that causes a concurrency conflict.</param>
 public AggregateRootConcurrencyConflict(AggregateRootVersion currentVersion, AggregateRootVersion commitVersion)
     : base($"Current Version is {currentVersion}, tried to commit {commitVersion}")
 {
 }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AggregateRootVersionIsOutOfOrder"/> class.
 /// </summary>
 /// <param name="eventVersion">The <see cref="AggregateRootVersion"/> the Event was applied by.</param>
 /// <param name="expectedVersion">Expected <see cref="AggregateRootVersion"/>.</param>
 public AggregateRootVersionIsOutOfOrder(AggregateRootVersion eventVersion, AggregateRootVersion expectedVersion)
     : base($"Aggregate Root version is out of order. Version '{eventVersion}' from event does not match '{expectedVersion}'")
 {
 }