mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-04-11 02:20:20 +08:00
27 lines
760 B
C#
27 lines
760 B
C#
using BuildingBlocks.Core.Event;
|
|
using BuildingBlocks.Core.Model;
|
|
|
|
namespace BuildingBlocks.EventStoreDB.Events
|
|
{
|
|
public abstract record AggregateEventSourcing<TId> : Entity<TId>, IAggregateEventSourcing<TId>
|
|
{
|
|
private readonly List<IDomainEvent> _domainEvents = new();
|
|
public IReadOnlyList<IDomainEvent> DomainEvents => _domainEvents.AsReadOnly();
|
|
|
|
public void AddDomainEvent(IDomainEvent domainEvent)
|
|
{
|
|
_domainEvents.Add(domainEvent);
|
|
}
|
|
|
|
public IDomainEvent[] ClearDomainEvents()
|
|
{
|
|
var dequeuedEvents = _domainEvents.ToArray();
|
|
|
|
_domainEvents.Clear();
|
|
|
|
return dequeuedEvents;
|
|
}
|
|
|
|
public virtual void When(object @event) { }
|
|
}
|
|
} |