This commit is contained in:
john 2025-05-03 15:38:57 +02:00
commit ab2e20f7e1
72 changed files with 2000 additions and 0 deletions

View file

@ -0,0 +1,21 @@
namespace Femto.Common.Domain;
public abstract class Entity
{
private readonly ICollection<IDomainEvent> _domainEvents = [];
protected void AddDomainEvent(IDomainEvent evt)
{
this._domainEvents.Add(evt);
}
public IList<IDomainEvent> DomainEvents => this._domainEvents.ToList();
public void ClearDomainEvents() => this._domainEvents.Clear();
protected void CheckRule(IRule rule)
{
if (!rule.Check())
throw new RuleBrokenException(rule.Message);
}
}