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; }
 }
        /// <summary>
        /// Creates and initializes the domain event data object from the given domain event.
        /// </summary>
        /// <param name="entity">The domain event instance from which the domain event data object
        /// is created and initialized.</param>
        /// <returns>The initialized data object instance.</returns>
        public static DomainEventDataObject FromDomainEvent(IDomainEvent entity)
        {
            IDomainEventSerializer serializer = GetDomainEventSerializer();
            DomainEventDataObject  obj        = new DomainEventDataObject();

            obj.Branch = entity.Branch;
            obj.Data   = serializer.Serialize(entity);
            obj.ID     = entity.ID;
            if (string.IsNullOrEmpty(entity.AssemblyQualifiedEventType))
            {
                obj.AssemblyQualifiedEventType = entity.GetType().AssemblyQualifiedName;
            }
            else
            {
                obj.AssemblyQualifiedEventType = entity.AssemblyQualifiedEventType;
            }
            obj.Timestamp = entity.Timestamp;
            obj.Version   = entity.Version;
            obj.SourceID  = entity.Source.ID;
            obj.AssemblyQualifiedSourceType = entity.Source.GetType().AssemblyQualifiedName;
            return(obj);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates and initializes the domain event data object from the given domain event.
 /// </summary>
 /// <param name="entity">The domain event instance from which the domain event data object
 /// is created and initialized.</param>
 /// <returns>The initialized data object instance.</returns>
 public static DomainEventDataObject FromDomainEvent(IDomainEvent entity)
 {
     IDomainEventSerializer serializer = GetDomainEventSerializer();
     DomainEventDataObject obj = new DomainEventDataObject();
     obj.Branch = entity.Branch;
     obj.Data = serializer.Serialize(entity);
     obj.ID = entity.ID;
     if (string.IsNullOrEmpty(entity.AssemblyQualifiedEventType))
         obj.AssemblyQualifiedEventType = entity.GetType().AssemblyQualifiedName;
     else
         obj.AssemblyQualifiedEventType = entity.AssemblyQualifiedEventType;
     obj.Timestamp = entity.Timestamp;
     obj.Version = entity.Version;
     obj.SourceID = entity.Source.ID;
     obj.AssemblyQualifiedSourceType = entity.Source.GetType().AssemblyQualifiedName;
     return obj;
 }