예제 #1
0
 //[DebuggerStepThrough]
 public void InvokeHandler(IDomainEvent e, EntityBase entity)
 {
     if (eventMutatesEntityState)
     {
         handler.Invoke(entity, new object[] {e});
     }
 }
예제 #2
0
        public virtual bool Equals(EntityBase other)
        {
            if (null != other && other.GetType() == GetType())
            {
                return other.Identity.Equals(Identity);
            }

            return false;
        }
예제 #3
0
        public void UpdateEventDetails(IDomainEvent e, IAggregate aggregate, EntityBase source)
        {
            versionProperty.SetValue(e, aggregate.GetVersion());
            aggregateIdentityProperty.SetValue(e, aggregate.Identity.GetId());

            if (entityIdentityProperty != null)
            {
                entityIdentityProperty.SetValue(e, source.Identity.GetId());
            }
        }
예제 #4
0
        public bool EventIsOwnedByEntity(IDomainEvent e, EntityBase entity)
        {
            if (entity.GetType() != entityType)
                return false;

            if (e.GetType() != eventType)
                return false;

            if (entityIdentityProperty == null)
            {
                object identity = aggregateIdentityProperty.GetValue(e);
                return entity.Identity.Equals(identity);
            }
            else
            {
                object identity = entityIdentityProperty.GetValue(e);
                return entity.Identity.Equals(identity);
            }
        }
예제 #5
0
        public static IReadOnlyCollection<EventHandlerProperties> ScanEntity(EntityBase entityBase)
        {
            var entityType = entityBase.GetType();

            try
            {
                readerWriterLock.EnterReadLock();

                if (eventHandlers.ContainsKey(entityType))
                {
                    return eventHandlers[entityType];
                }
            }
            finally
            {
                readerWriterLock.ExitReadLock();
            }

            ScanTypeForHandlers(entityType);
            return eventHandlers[entityType];
        }
 public EventHandlerNotFoundException(EntityBase entity, IAggregateEvent @event)
     : base(GetErrorMessage(entity, @event))
 {
 }
 private static string GetErrorMessage(EntityBase entity, IAggregateEvent @event)
 {
     return String.Format("Unable to locate an event handler for {0} on {1}", @event.GetType().FullName, entity.GetType().FullName);
 }
예제 #8
0
 protected internal abstract void SaveEvent(IAggregateEvent @event, EntityBase source);
 private static string GetErrorMessage(EntityBase entity, IDomainEvent @event)
 {
     return String.Format("An error occured while invoking event handler {0} on {1}", @event.GetType().FullName, entity.GetType().FullName);
 }
 public EventHandlerInvocationException(EntityBase entity, IDomainEvent @event, TargetInvocationException ex)
     : base(GetErrorMessage(entity, @event), ex.InnerException ?? ex)
 {
 }
예제 #11
0
 protected internal abstract void SaveEvent(IDomainEvent @event, EntityBase source);