Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Event"/> class.
 /// </summary>
 /// <param name="eventLogSequenceNumber">The event log sequence number of this event.</param>
 /// <param name="executionContext">The execution context.</param>
 /// <param name="metadata">The event metadata.</param>
 /// <param name="aggregate">The aggregate metadata.</param>
 /// <param name="eventHorizonMetadata">The event horizon metadata.</param>
 /// <param name="content">The event content.</param>
 public Event(
     ulong eventLogSequenceNumber,
     ExecutionContext executionContext,
     EventMetadata metadata,
     AggregateMetadata aggregate,
     EventHorizonMetadata eventHorizonMetadata,
     BsonDocument content)
 {
     EventLogSequenceNumber = eventLogSequenceNumber;
     ExecutionContext       = executionContext;
     Metadata     = metadata;
     Aggregate    = aggregate;
     EventHorizon = eventHorizonMetadata;
     Content      = content;
 }
Ejemplo n.º 2
0
    /// <inheritdoc />
    public IEnumerable <Events.Event> ToEvents(Commit commit)
    {
        var eventsInCommit          = commit.Events.ToArray();
        var aggregateEventsInCommit = commit.AggregateEvents.ToArray();

        if (eventsInCommit.Length == 0 && aggregateEventsInCommit.Length == 0)
        {
            return(Enumerable.Empty <Events.Event>());
        }

        var eventsToStore        = new List <MongoDB.Events.Event>();
        var eventHorizonMetadata = new EventHorizonMetadata();

        foreach (var committedEvents in eventsInCommit)
        {
            var executionContext  = committedEvents.First().ExecutionContext.ToStoreRepresentation();
            var aggregateMetadata = new AggregateMetadata();
            eventsToStore.AddRange(committedEvents.Select(_ => new Events.Event(
                                                              _.EventLogSequenceNumber,
                                                              executionContext,
                                                              new EventMetadata(
                                                                  _.Occurred.UtcDateTime,
                                                                  _.EventSource,
                                                                  _.Type.Id,
                                                                  _.Type.Generation,
                                                                  _.Public),
                                                              aggregateMetadata,
                                                              eventHorizonMetadata,
                                                              BsonDocument.Parse(_.Content))));
        }
        foreach (var committedEvents in aggregateEventsInCommit)
        {
            var executionContext = committedEvents.First().ExecutionContext.ToStoreRepresentation();
            eventsToStore.AddRange(committedEvents.Select(_ => new Events.Event(
                                                              _.EventLogSequenceNumber,
                                                              executionContext,
                                                              new EventMetadata(
                                                                  _.Occurred.UtcDateTime,
                                                                  _.EventSource,
                                                                  _.Type.Id,
                                                                  _.Type.Generation,
                                                                  _.Public),
                                                              new AggregateMetadata(true, _.AggregateRoot.Id, _.AggregateRoot.Generation, _.AggregateRootVersion),
                                                              eventHorizonMetadata,
                                                              BsonDocument.Parse(_.Content))));
        }
        return(eventsToStore);
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StreamEvent"/> class.
 /// </summary>
 /// <param name="streamPosition">The position in the stream.</param>
 /// <param name="partition">The partition id.</param>
 /// <param name="executionContext">The execution context.</param>
 /// <param name="metadata">The event metadata.</param>
 /// <param name="aggregate">The aggregate metadata.</param>
 /// <param name="eventHorizonMetadata">The event horizon metadata.</param>
 /// <param name="content">The event content.</param>
 public StreamEvent(
     ulong streamPosition,
     PartitionId partition,
     ExecutionContext executionContext,
     StreamEventMetadata metadata,
     AggregateMetadata aggregate,
     EventHorizonMetadata eventHorizonMetadata,
     BsonDocument content)
 {
     StreamPosition   = streamPosition;
     Partition        = partition;
     ExecutionContext = executionContext;
     Metadata         = metadata;
     Aggregate        = aggregate;
     EventHorizon     = eventHorizonMetadata;
     Content          = content;
 }