mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-04-11 10:32:09 +08:00
24 lines
577 B
C#
24 lines
577 B
C#
using BuildingBlocks.Core.Event;
|
|
|
|
namespace BuildingBlocks.Core.Model;
|
|
|
|
public abstract record Aggregate<TId> : Entity<TId>, IAggregate<TId>
|
|
{
|
|
private readonly List<IDomainEvent> _domainEvents = new();
|
|
public IReadOnlyList<IDomainEvent> DomainEvents => _domainEvents.AsReadOnly();
|
|
|
|
public void AddDomainEvent(IDomainEvent domainEvent)
|
|
{
|
|
_domainEvents.Add(domainEvent);
|
|
}
|
|
|
|
public IEvent[] ClearDomainEvents()
|
|
{
|
|
IEvent[] dequeuedEvents = _domainEvents.ToArray();
|
|
|
|
_domainEvents.Clear();
|
|
|
|
return dequeuedEvents;
|
|
}
|
|
}
|