Ejemplo n.º 1
0
 /// <summary>
 /// Saves the specified domain event to the event storage.
 /// </summary>
 /// <param name="domainEvent">The domain event to be saved.</param>
 public void SaveEvent(IDomainEvent domainEvent)
 {
     try
     {
         DomainEventDataObject dataObject = DomainEventDataObject.FromDomainEvent(domainEvent);
         storage.Insert <DomainEventDataObject>(new PropertyBag(dataObject));
     }
     catch { throw; }
 }
Ejemplo n.º 2
0
        // crate and initializes the domain event data object from given domain event
        public static DomainEventDataObject FromDomainEvent(IDomainEvent @event)
        {
            IDomainEventSerializer serializer     = GetDomainEventSerializer();
            DomainEventDataObject  domainEventDto = new DomainEventDataObject();

            domainEventDto.Data = serializer.Serialize(@event);
            domainEventDto.Id   = @event.Id;
            if (string.IsNullOrEmpty(@event.AssemblyQualifiedEventType))
            {
                domainEventDto.AssemblyQualifiedEventType = @event.GetType().AssemblyQualifiedName;
            }
            else
            {
                domainEventDto.AssemblyQualifiedEventType = @event.AssemblyQualifiedEventType;
            }
            domainEventDto.Timestamp = @event.Timestamp;
            domainEventDto.Version   = @event.Version;
            domainEventDto.SourceId  = @event.Source.Id;
            domainEventDto.AssemblyQualifiedSourceType = @event.Source.GetType().AssemblyQualifiedName;
            return(domainEventDto);
        }