Ejemplo n.º 1
0
        /// <summary>
        /// 从指定的领域事件中创建并初始化领域事件数据对象
        /// </summary>
        /// <param name="entity">要创建并初始化领域事件数据对象实例</param>
        /// <returns>初始化的数据对象实例</returns>
        public static DomainEventDataObject FromDomainEvent(IDomainEvent entity)
        {
            var serializer = GetDomainEventSerializer();
            var obj        = new DomainEventDataObject
            {
                Data = serializer.Serialize(entity),
                ID   = entity.ID,
                AssemblyQualifiedEventType =
                    string.IsNullOrEmpty(entity.AssemblyQualifiedEventType)
                        ? entity.GetType().AssemblyQualifiedName
                        : entity.AssemblyQualifiedEventType,
                Timestamp = entity.Timestamp,
                Version   = entity.Version,
                SourceID  = entity.Source.ID,
                AssemblyQualifiedSourceType = entity.Source.GetType().AssemblyQualifiedName
            };

            return(obj);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 从指定的领域事件中创建并初始化领域事件数据对象
        /// </summary>
        /// <param name="entity">要创建并初始化领域事件数据对象实例</param>
        /// <returns>初始化的数据对象实例</returns>
        public static DomainEventDataObject FromDomainEvent(IDomainEvent entity)
        {
            var serializer = GetDomainEventSerializer();
            var obj = new DomainEventDataObject
            {
                Data = serializer.Serialize(entity),
                ID = entity.ID,
                AssemblyQualifiedEventType =
                    string.IsNullOrEmpty(entity.AssemblyQualifiedEventType)
                        ? entity.GetType().AssemblyQualifiedName
                        : entity.AssemblyQualifiedEventType,
                Timestamp = entity.Timestamp,
                Version = entity.Version,
                SourceID = entity.Source.ID,
                AssemblyQualifiedSourceType = entity.Source.GetType().AssemblyQualifiedName
            };

            return obj;
        }