//[DebuggerStepThrough] public void InvokeHandler(IDomainEvent e, EntityBase entity) { if (eventMutatesEntityState) { handler.Invoke(entity, new object[] {e}); } }
public virtual bool Equals(EntityBase other) { if (null != other && other.GetType() == GetType()) { return other.Identity.Equals(Identity); } return false; }
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()); } }
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); } }
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); }
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) { }
protected internal abstract void SaveEvent(IDomainEvent @event, EntityBase source);