Esempio n. 1
0
        /// <summary>
        /// Creates a <see cref="StorableEvent" /> based on the specified domain event.
        /// </summary>
        /// <param name="domainEvent">The domain event.</param>
        public static StorableEvent ToStorableEvent(this IEvent domainEvent)
        {
            if (domainEvent == null)
            {
                throw new ArgumentNullException(nameof(domainEvent));
            }

            string eventStreamName = null;
            var    aggregateType   = domainEvent.AggregateType();

            eventStreamName = aggregateType != null
                                  ? AggregateType.EventStreamName(aggregateType)
                                  : ((dynamic)domainEvent).EventStreamName;

            return(new StorableEvent
            {
                Actor = domainEvent.Actor(),
                StreamName = eventStreamName,
                SequenceNumber = domainEvent.SequenceNumber,
                AggregateId = domainEvent.AggregateId,
                Type = domainEvent.EventName(),
                Body = JsonConvert.SerializeObject(domainEvent, Formatting.None, serializerSettings.Value),
                Timestamp = domainEvent.Timestamp,
                ETag = domainEvent.ETag,
                Id = domainEvent.AbsoluteSequenceNumber()
            });
        }
Esempio n. 2
0
 private static EventHandlingError CreateEventHandlingError(IEvent e) =>
 new EventHandlingError
 {
     Actor           = e.Actor(),
     AggregateId     = e.AggregateId,
     SequenceNumber  = e.SequenceNumber,
     SerializedEvent = e.ToJson(),
     StreamName      = e.EventStreamName(),
     EventTypeName   = e.EventName(),
     OriginalId      = null
 };
Esempio n. 3
0
 /// <summary>
 /// Creates a <see cref="StorableEvent" /> based on the specified domain event.
 /// </summary>
 /// <param name="domainEvent">The domain event.</param>
 internal static StorableEvent ToStorableEvent <TAggregate>(this IEvent <TAggregate> domainEvent)
     where TAggregate : IEventSourced =>
 new StorableEvent
 {
     Actor          = domainEvent.Actor(),
     StreamName     = AggregateType <TAggregate> .EventStreamName,
     SequenceNumber = domainEvent.SequenceNumber,
     AggregateId    = domainEvent.AggregateId,
     Type           = domainEvent.EventName(),
     Body           = JsonConvert.SerializeObject(domainEvent, Formatting.None, serializerSettings.Value),
     Timestamp      = domainEvent.Timestamp,
     ETag           = domainEvent.ETag
 };
Esempio n. 4
0
 /// <summary>
 /// Creates a <see cref="StorableEvent" /> based on the specified domain event.
 /// </summary>
 /// <param name="domainEvent">The domain event.</param>
 /// <param name="serialize">Serializes the domain event.</param>
 internal static StorableEvent ToStorableEvent <TAggregate>(this IEvent <TAggregate> domainEvent, SerializeEvent serialize)
     where TAggregate : IEventSourced
 {
     return(new StorableEvent
     {
         Actor = domainEvent.Actor(),
         StreamName = AggregateType <TAggregate> .EventStreamName,
         SequenceNumber = domainEvent.SequenceNumber,
         AggregateId = domainEvent.AggregateId,
         Type = domainEvent.EventName(),
         Body = serialize(domainEvent),
         Timestamp = domainEvent.Timestamp,
         ETag = domainEvent.ETag
     });
 }
Esempio n. 5
0
 private static EventHandlingError CreateEventHandlingError(IEvent e) =>
     new EventHandlingError
     {
         Actor = e.Actor(),
         AggregateId = e.AggregateId,
         SequenceNumber = e.SequenceNumber,
         SerializedEvent = e.ToJson(),
         StreamName = e.EventStreamName(),
         EventTypeName = e.EventName(),
         OriginalId = null
     };