From a4245fdd93c51559d941e9ba7b23501b65e1d0bf Mon Sep 17 00:00:00 2001 From: Veljko Tosic Date: Wed, 11 Feb 2026 02:19:42 +0100 Subject: [PATCH] Abstract base for new domain --- .../AipsCore/Domain/Abstract/DomainEntity.cs | 26 +++++++++++++++++++ .../Domain/Abstract/IAbstractRepository.cs | 12 +++++++++ .../AipsCore/Domain/Abstract/IDomainEvent.cs | 6 +++++ 3 files changed, 44 insertions(+) create mode 100644 dotnet/AipsCore/Domain/Abstract/DomainEntity.cs create mode 100644 dotnet/AipsCore/Domain/Abstract/IAbstractRepository.cs create mode 100644 dotnet/AipsCore/Domain/Abstract/IDomainEvent.cs diff --git a/dotnet/AipsCore/Domain/Abstract/DomainEntity.cs b/dotnet/AipsCore/Domain/Abstract/DomainEntity.cs new file mode 100644 index 0000000..90a43b5 --- /dev/null +++ b/dotnet/AipsCore/Domain/Abstract/DomainEntity.cs @@ -0,0 +1,26 @@ +using AipsCore.Domain.Common.ValueObjects; + +namespace AipsCore.Domain.Abstract; + +public abstract class DomainEntity where TId : DomainId +{ + private readonly List _domainEvents = []; + + public TId Id { get; init; } + + protected DomainEntity() + { + + } + + protected DomainEntity(TId id) + { + Id = id; + } + + public IReadOnlyList GetDomainEvents() => _domainEvents.ToList(); + + public void ClearDomainEvents() => _domainEvents.Clear(); + + protected void RaiseDomainEvent(IDomainEvent domainEvent) => _domainEvents.Add(domainEvent); +} \ No newline at end of file diff --git a/dotnet/AipsCore/Domain/Abstract/IAbstractRepository.cs b/dotnet/AipsCore/Domain/Abstract/IAbstractRepository.cs new file mode 100644 index 0000000..c41fbd6 --- /dev/null +++ b/dotnet/AipsCore/Domain/Abstract/IAbstractRepository.cs @@ -0,0 +1,12 @@ +using AipsCore.Domain.Common.ValueObjects; + +namespace AipsCore.Domain.Abstract; + +public interface IAbstractRepository + where TEntity : DomainEntity + where TId : DomainId +{ + Task GetByIdAsync(TId id, CancellationToken cancellationToken = default); + Task SaveAsync(TEntity entity, CancellationToken cancellationToken = default); + Task AddAsync(TEntity entity, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/dotnet/AipsCore/Domain/Abstract/IDomainEvent.cs b/dotnet/AipsCore/Domain/Abstract/IDomainEvent.cs new file mode 100644 index 0000000..75209ae --- /dev/null +++ b/dotnet/AipsCore/Domain/Abstract/IDomainEvent.cs @@ -0,0 +1,6 @@ +namespace AipsCore.Domain.Abstract; + +public interface IDomainEvent +{ + +} \ No newline at end of file