Merge pull request #561 from Alexbits/hotfix/EntityEncapsulationFix
Improved encapsulation of DomainEvents collection in Entity class
This commit is contained in:
commit
f2a4f3ac2c
@ -21,17 +21,22 @@
|
||||
}
|
||||
|
||||
private List<INotification> _domainEvents;
|
||||
public List<INotification> DomainEvents => _domainEvents;
|
||||
|
||||
public IReadOnlyCollection<INotification> DomainEvents => _domainEvents?.AsReadOnly();
|
||||
|
||||
public void AddDomainEvent(INotification eventItem)
|
||||
{
|
||||
_domainEvents = _domainEvents ?? new List<INotification>();
|
||||
_domainEvents.Add(eventItem);
|
||||
}
|
||||
|
||||
public void RemoveDomainEvent(INotification eventItem)
|
||||
{
|
||||
if (_domainEvents is null) return;
|
||||
_domainEvents.Remove(eventItem);
|
||||
_domainEvents?.Remove(eventItem);
|
||||
}
|
||||
|
||||
public void ClearDomainEvents()
|
||||
{
|
||||
_domainEvents?.Clear();
|
||||
}
|
||||
|
||||
public bool IsTransient()
|
||||
|
@ -19,7 +19,7 @@ namespace Ordering.Infrastructure
|
||||
.ToList();
|
||||
|
||||
domainEntities.ToList()
|
||||
.ForEach(entity => entity.Entity.DomainEvents.Clear());
|
||||
.ForEach(entity => entity.Entity.ClearDomainEvents());
|
||||
|
||||
var tasks = domainEvents
|
||||
.Select(async (domainEvent) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user