diff --git a/Toolbox.jpeg b/Toolbox.jpeg
new file mode 100644
index 0000000..a3fdcf8
Binary files /dev/null and b/Toolbox.jpeg differ
diff --git a/src/Modular.Monolithic.Architecture.Helper.Domain/Abstractions/IAuditableEntity.cs b/src/Modular.Monolithic.Architecture.Helper.Domain/Abstractions/IAuditableEntity.cs
index 77cf562..e8f84e2 100644
--- a/src/Modular.Monolithic.Architecture.Helper.Domain/Abstractions/IAuditableEntity.cs
+++ b/src/Modular.Monolithic.Architecture.Helper.Domain/Abstractions/IAuditableEntity.cs
@@ -1,22 +1,17 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+namespace Modular.Monolithic.Architecture.Helper.Domain.Abstractions;
-namespace Modular.Monolithic.Architecture.Helper.Domain.Abstractions
+///
+/// Represents the marker interface for auditable entities.
+///
+public interface IAuditableEntity
{
///
- /// Represents the marker interface for auditable entities.
+ /// Gets the created on date and time in UTC format.
///
- public interface IAuditableEntity
- {
- ///
- /// Gets the created on date and time in UTC format.
- ///
- DateTime CreatedOn { get; }
+ DateTime CreatedOn { get; }
- ///
- /// Gets the modified on date and time in UTC format.
- ///
- DateTime? ModifiedOn { get; }
- }
+ ///
+ /// Gets the modified on date and time in UTC format.
+ ///
+ DateTime? ModifiedOn { get; }
}
diff --git a/src/Modular.Monolithic.Architecture.Helper.Domain/Abstractions/ISoftDeletableEntity.cs b/src/Modular.Monolithic.Architecture.Helper.Domain/Abstractions/ISoftDeletableEntity.cs
index 5de18d0..b9b0ef7 100644
--- a/src/Modular.Monolithic.Architecture.Helper.Domain/Abstractions/ISoftDeletableEntity.cs
+++ b/src/Modular.Monolithic.Architecture.Helper.Domain/Abstractions/ISoftDeletableEntity.cs
@@ -1,22 +1,17 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+namespace Modular.Monolithic.Architecture.Helper.Domain.Abstractions;
-namespace Modular.Monolithic.Architecture.Helper.Domain.Abstractions
+///
+/// Represents the marker interface for soft-deletable entities.
+///
+public interface ISoftDeletableEntity
{
///
- /// Represents the marker interface for soft-deletable entities.
+ /// Gets the date and time in UTC format the entity was deleted on.
///
- public interface ISoftDeletableEntity
- {
- ///
- /// Gets the date and time in UTC format the entity was deleted on.
- ///
- DateTime? DeletedOn { get; }
+ DateTime? DeletedOn { get; }
- ///
- /// Gets a value indicating whether the entity has been deleted.
- ///
- bool Deleted { get; }
- }
+ ///
+ /// Gets a value indicating whether the entity has been deleted.
+ ///
+ bool Deleted { get; }
}
diff --git a/src/Modular.Monolithic.Architecture.Helper.Domain/Abstractions/TypedIdValueBase.cs b/src/Modular.Monolithic.Architecture.Helper.Domain/Abstractions/TypedIdValueBase.cs
new file mode 100644
index 0000000..bcde825
--- /dev/null
+++ b/src/Modular.Monolithic.Architecture.Helper.Domain/Abstractions/TypedIdValueBase.cs
@@ -0,0 +1,60 @@
+namespace Modular.Monolithic.Architecture.Helper.Domain.Abstractions;
+
+///
+/// Represents the id value entities.
+///
+public abstract class TypedIdValueBase : IEquatable
+{
+ ///
+ /// Gets or sets the entity identifier.
+ ///
+ public Guid Value { get; private set; }
+
+ protected TypedIdValueBase(Guid value)
+ {
+ if (value == Guid.Empty)
+ {
+ throw new InvalidOperationException("Id value cannot be empty!");
+ }
+
+ Value = value;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool operator ==(TypedIdValueBase left, TypedIdValueBase right)
+ {
+ if (Object.Equals(left, null))
+ {
+ return Object.Equals(right, null);
+ }
+ else
+ {
+ return left.Equals(right);
+ }
+ }
+
+ public static bool operator !=(TypedIdValueBase left, TypedIdValueBase right) => !(left == right);
+
+ ///
+ public bool IsTransient() => Value == default;
+
+ ///
+ public override bool Equals(object obj)
+ {
+ if (obj is null)
+ {
+ return false;
+ }
+
+ return obj is TypedIdValueBase other && Equals(other);
+ }
+ //
+ public bool Equals(TypedIdValueBase other) => Value == other?.Value;
+ ///
+ public override int GetHashCode() => Value.GetHashCode();
+}
diff --git a/src/Modular.Monolithic.Architecture.Helper.Domain/BusinessRules/IBusinessRule.cs b/src/Modular.Monolithic.Architecture.Helper.Domain/BusinessRules/IBusinessRule.cs
index 16ff36d..3911cdc 100644
--- a/src/Modular.Monolithic.Architecture.Helper.Domain/BusinessRules/IBusinessRule.cs
+++ b/src/Modular.Monolithic.Architecture.Helper.Domain/BusinessRules/IBusinessRule.cs
@@ -1,13 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Modular.Monolithic.Architecture.Helper.Domain.Errors;
+using Modular.Monolithic.Architecture.Helper.Domain.Errors;
-namespace Modular.Monolithic.Architecture.Helper.Domain.BusinessRules
+namespace Modular.Monolithic.Architecture.Helper.Domain.BusinessRules;
+
+public interface IBusinessRule
{
- public interface IBusinessRule
- {
- bool IsFail();
- Error Error { get; }
- }
+ bool IsFail();
+ Error Error { get; }
}
diff --git a/src/Modular.Monolithic.Architecture.Helper.Domain/Core/AggregateRoot.cs b/src/Modular.Monolithic.Architecture.Helper.Domain/Core/AggregateRoot.cs
index c55bf51..8e3b6b2 100644
--- a/src/Modular.Monolithic.Architecture.Helper.Domain/Core/AggregateRoot.cs
+++ b/src/Modular.Monolithic.Architecture.Helper.Domain/Core/AggregateRoot.cs
@@ -1,11 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+namespace Modular.Monolithic.Architecture.Helper.Domain.Core;
-namespace Modular.Monolithic.Architecture.Helper.Domain.Core
-{
- ///
- ///
- ///
- public abstract class AggregateRoot : Entity { }
-}
+///
+///
+///
+public abstract class AggregateRoot : Entity { }
diff --git a/src/Modular.Monolithic.Architecture.Helper.Domain/Core/Entity.cs b/src/Modular.Monolithic.Architecture.Helper.Domain/Core/Entity.cs
index 4977db7..ad68236 100644
--- a/src/Modular.Monolithic.Architecture.Helper.Domain/Core/Entity.cs
+++ b/src/Modular.Monolithic.Architecture.Helper.Domain/Core/Entity.cs
@@ -1,135 +1,58 @@
-using System;
-using System.Collections.Generic;
-using Modular.Monolithic.Architecture.Helper.Domain.BusinessRules;
+using Modular.Monolithic.Architecture.Helper.Domain.BusinessRules;
using Modular.Monolithic.Architecture.Helper.Domain.Events;
using Modular.Monolithic.Architecture.Helper.Domain.Exceptions;
-namespace Modular.Monolithic.Architecture.Helper.Domain.Core
+namespace Modular.Monolithic.Architecture.Helper.Domain.Core;
+
+///
+/// Represents the base class that all entities derive from.
+///
+public abstract class Entity
{
+
+ private List _domainEvents;
+
///
- /// Represents the base class that all entities derive from.
+ /// Domain events occurred.
///
- public abstract class Entity : IEquatable
+ public IReadOnlyCollection? DomainEvents => _domainEvents?.AsReadOnly();
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// Required by EF Core.
+ ///
+ protected Entity()
{
-
- private List _domainEvents;
-
- ///
- /// Domain events occurred.
- ///
- public IReadOnlyCollection DomainEvents => _domainEvents?.AsReadOnly();
- ///
- /// Gets or sets the entity identifier.
- ///
- public Guid Id { get; private set; }
- ///
- /// Initializes a new instance of the class.
- ///
- /// The entity identifier.
- protected Entity(Guid id)
- : this()
- {
- Id = id;
- }
- ///
- /// Initializes a new instance of the class.
- ///
- ///
- /// Required by EF Core.
- ///
- protected Entity()
- {
- }
- ///
- ///
- ///
- ///
- public void AddDomainEvent(IDomainEvent eventItem)
- {
- _domainEvents = _domainEvents ?? new List();
- _domainEvents.Add(eventItem);
- }
- ///
- ///
- ///
- ///
- public void RemoveDomainEvent(IDomainEvent eventItem)
- {
- _domainEvents?.Remove(eventItem);
- }
- ///
- ///
- ///
- public void ClearDomainEvents()
- {
- _domainEvents?.Clear();
- }
- ///
- ///
- ///
- ///
- ///
- protected void CheckRule(IBusinessRule rule)
- {
- if (rule.IsFail())
- {
- throw new BusinessRuleValidationException(rule);
- }
- }
- ///
- ///
- ///
- ///
- ///
- ///
- public static bool operator ==(Entity left, Entity right)
- {
- if (Object.Equals(left, null))
- return (Object.Equals(right, null)) ? true : false;
- else
- return left.Equals(right);
- }
-
- public static bool operator !=(Entity left, Entity right)
- {
- return !(left == right);
- }
-
- ///
- public bool IsTransient()
- {
- return this.Id == default;
- }
- ///
- public bool Equals(Entity other)
- {
- if (other is null)
- {
- return false;
- }
-
- return ReferenceEquals(this, other) || Id == other.Id;
- }
- ///
- public override bool Equals(object obj)
+ }
+ ///
+ ///
+ ///
+ ///
+ public void AddDomainEvent(IDomainEvent eventItem)
+ {
+ _domainEvents ??= [];
+ _domainEvents.Add(eventItem);
+ }
+ ///
+ ///
+ ///
+ ///
+ public void RemoveDomainEvent(IDomainEvent eventItem) => _domainEvents?.Remove(eventItem);
+ ///
+ ///
+ ///
+ public void ClearDomainEvents() => _domainEvents?.Clear();
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected void CheckRule(IBusinessRule rule)
+ {
+ if (rule.IsFail())
{
- if (obj == null || !(obj is Entity))
- return false;
-
- if (Object.ReferenceEquals(this, obj))
- return true;
-
- if (this.GetType() != obj.GetType())
- return false;
-
- Entity item = (Entity)obj;
-
- if (item.IsTransient() || this.IsTransient())
- return false;
- else
- return item.Id == this.Id;
+ throw new BusinessRuleValidationException(rule);
}
- ///
- public override int GetHashCode() => this.Id.GetHashCode() ^ 31;
}
}
diff --git a/src/Modular.Monolithic.Architecture.Helper.Domain/Core/ValueObject.cs b/src/Modular.Monolithic.Architecture.Helper.Domain/Core/ValueObject.cs
index 0484d8f..2626556 100644
--- a/src/Modular.Monolithic.Architecture.Helper.Domain/Core/ValueObject.cs
+++ b/src/Modular.Monolithic.Architecture.Helper.Domain/Core/ValueObject.cs
@@ -1,60 +1,54 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+namespace Modular.Monolithic.Architecture.Helper.Domain.Core;
-namespace Modular.Monolithic.Architecture.Helper.Domain.Core
+///
+///
+///
+public abstract class ValueObject : IEquatable
{
- ///
- ///
- ///
- public abstract class ValueObject : IEquatable
+ public static bool operator ==(ValueObject a, ValueObject b)
{
- public static bool operator ==(ValueObject a, ValueObject b)
+ if (a is null && b is null)
{
- if (a is null && b is null)
- {
- return true;
- }
-
- if (a is null || b is null)
- {
- return false;
- }
-
- return a.Equals(b);
+ return true;
}
- public static bool operator !=(ValueObject a, ValueObject b) => !(a == b);
-
- ///
- public bool Equals(ValueObject other) => !(other is null) && GetValues().SequenceEqual(other.GetValues());
-
- ///
- public override bool Equals(object obj)
+ if (a is null || b is null)
{
- if (obj == null || obj.GetType() != GetType())
- {
- return false;
- }
+ return false;
+ }
- var other = (ValueObject)obj;
+ return a.Equals(b);
+ }
- return GetValues().SequenceEqual(other.GetValues());
- }
+ public static bool operator !=(ValueObject a, ValueObject b) => !(a == b);
- ///
- public override int GetHashCode()
+ ///
+ public bool Equals(ValueObject other) => other is not null && GetValues().SequenceEqual(other.GetValues());
+
+ ///
+ public override bool Equals(object obj)
+ {
+ if (obj == null || obj.GetType() != GetType())
{
- return GetValues()
- .Select(x => x != null ? x.GetHashCode() : 0)
- .Aggregate((x, y) => x ^ y);
+ return false;
}
- ///
- /// Gets the atomic values of the value object.
- ///
- /// The collection of objects representing the value object values.
- protected abstract IEnumerable