|
|
|
@ -7,28 +7,45 @@ namespace Volo.Abp.Domain.Entities
|
|
|
|
|
[Serializable]
|
|
|
|
|
public abstract class AggregateRoot : Entity, IAggregateRoot, IGeneratesDomainEvents
|
|
|
|
|
{
|
|
|
|
|
private readonly ICollection<object> _domainEvents = new Collection<object>();
|
|
|
|
|
private readonly ICollection<object> _localEvents = new Collection<object>();
|
|
|
|
|
private readonly ICollection<object> _distributedEvents = new Collection<object>();
|
|
|
|
|
|
|
|
|
|
protected virtual void AddDomainEvent(object eventData)
|
|
|
|
|
protected virtual void AddLocalEvent(object eventData)
|
|
|
|
|
{
|
|
|
|
|
_domainEvents.Add(eventData);
|
|
|
|
|
_localEvents.Add(eventData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual IEnumerable<object> GetDomainEvents()
|
|
|
|
|
protected virtual void AddDistributedEvent(object eventData)
|
|
|
|
|
{
|
|
|
|
|
return _domainEvents;
|
|
|
|
|
_distributedEvents.Add(eventData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void ClearDomainEvents()
|
|
|
|
|
public virtual IEnumerable<object> GetLocalEvents()
|
|
|
|
|
{
|
|
|
|
|
_domainEvents.Clear();
|
|
|
|
|
return _localEvents;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<object> GetDistributedEvents()
|
|
|
|
|
{
|
|
|
|
|
return _distributedEvents;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void ClearLocalEvents()
|
|
|
|
|
{
|
|
|
|
|
_localEvents.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClearDistributedEvents()
|
|
|
|
|
{
|
|
|
|
|
_distributedEvents.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
public abstract class AggregateRoot<TKey> : Entity<TKey>, IAggregateRoot<TKey>, IGeneratesDomainEvents
|
|
|
|
|
{
|
|
|
|
|
private readonly ICollection<object> _domainEvents = new Collection<object>();
|
|
|
|
|
private readonly ICollection<object> _localEvents = new Collection<object>();
|
|
|
|
|
private readonly ICollection<object> _distributedEvents = new Collection<object>();
|
|
|
|
|
|
|
|
|
|
protected AggregateRoot()
|
|
|
|
|
{
|
|
|
|
@ -41,19 +58,34 @@ namespace Volo.Abp.Domain.Entities
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void AddDomainEvent(object eventData)
|
|
|
|
|
protected virtual void AddLocalEvent(object eventData)
|
|
|
|
|
{
|
|
|
|
|
_localEvents.Add(eventData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void AddDistributedEvent(object eventData)
|
|
|
|
|
{
|
|
|
|
|
_distributedEvents.Add(eventData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual IEnumerable<object> GetLocalEvents()
|
|
|
|
|
{
|
|
|
|
|
return _localEvents;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<object> GetDistributedEvents()
|
|
|
|
|
{
|
|
|
|
|
_domainEvents.Add(eventData);
|
|
|
|
|
return _distributedEvents;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual IEnumerable<object> GetDomainEvents()
|
|
|
|
|
public virtual void ClearLocalEvents()
|
|
|
|
|
{
|
|
|
|
|
return _domainEvents;
|
|
|
|
|
_localEvents.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void ClearDomainEvents()
|
|
|
|
|
public void ClearDistributedEvents()
|
|
|
|
|
{
|
|
|
|
|
_domainEvents.Clear();
|
|
|
|
|
_distributedEvents.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|