mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Normalize line endings
This commit is contained in:
1 parent
6bcb337b00
commit
2f18966180
19 files changed
+874
-874
No files matched your search
@@ -1,29 +1,29 @@
|
||||
namespace Lumina.Domain.Common.Models.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for all domain Aggregate Roots.
|
||||
/// </summary>
|
||||
/// <typeparam name="TId">The type representing the unique identifier for the Aggregate Root. It should be a non-nullable type.</typeparam>
|
||||
public abstract class AggregateRoot<TId> : Entity<TId> where TId : notnull
|
||||
{
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AggregateRoot{TId}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The id of the entity.</param>
|
||||
protected AggregateRoot(TId id) : base(id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AggregateRoot{TId}"/> class.
|
||||
/// </summary>
|
||||
protected AggregateRoot() // only needed during reflection
|
||||
namespace Lumina.Domain.Common.Models.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for all domain Aggregate Roots.
|
||||
/// </summary>
|
||||
/// <typeparam name="TId">The type representing the unique identifier for the Aggregate Root. It should be a non-nullable type.</typeparam>
|
||||
public abstract class AggregateRoot<TId> : Entity<TId> where TId : notnull
|
||||
{
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AggregateRoot{TId}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The id of the entity.</param>
|
||||
protected AggregateRoot(TId id) : base(id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AggregateRoot{TId}"/> class.
|
||||
/// </summary>
|
||||
protected AggregateRoot() // only needed during reflection
|
||||
{
|
||||
|
||||
}
|
||||
#pragma warning restore CS8618
|
||||
#endregion
|
||||
}
|
||||
#pragma warning restore CS8618
|
||||
#endregion
|
||||
}
|
||||
@@ -1,103 +1,103 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.Models.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for all domain Entities.
|
||||
/// </summary>
|
||||
/// <typeparam name="TId">The type representing the unique identifier for the Entity. It should be a non-nullable type.</typeparam>
|
||||
public abstract class Entity<TId> : IEquatable<Entity<TId>> where TId : notnull
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the unique identifier of the entity.
|
||||
/// </summary>
|
||||
public TId Id { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date and time when the entity was created.
|
||||
/// </summary>
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date and time when the entity was last updated.
|
||||
/// </summary>
|
||||
public DateTime? Updated { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Entity{TId}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The id of the entity.</param>
|
||||
protected Entity(TId id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Entity{TId}"/> class.
|
||||
/// </summary>
|
||||
protected Entity() // only needed during reflection
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.Models.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for all domain Entities.
|
||||
/// </summary>
|
||||
/// <typeparam name="TId">The type representing the unique identifier for the Entity. It should be a non-nullable type.</typeparam>
|
||||
public abstract class Entity<TId> : IEquatable<Entity<TId>> where TId : notnull
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the unique identifier of the entity.
|
||||
/// </summary>
|
||||
public TId Id { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date and time when the entity was created.
|
||||
/// </summary>
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date and time when the entity was last updated.
|
||||
/// </summary>
|
||||
public DateTime? Updated { get; set; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Entity{TId}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The id of the entity.</param>
|
||||
protected Entity(TId id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Entity{TId}"/> class.
|
||||
/// </summary>
|
||||
protected Entity() // only needed during reflection
|
||||
{
|
||||
|
||||
}
|
||||
#pragma warning restore CS8618
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Indicates whether the current object is equal to another object of the same type.
|
||||
/// </summary>
|
||||
/// <param name="other">An object to compare with this object.</param>
|
||||
/// <returns><see langword="true"/> if the current object is equal to the other parameter, <see langword="false"/> otherwise.</returns>
|
||||
public bool Equals(Entity<TId>? other)
|
||||
{
|
||||
return Equals((object?)other);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified objects' Id is equal to the current objects' Id.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object whose Id is compared with the current objects' Id.</param>
|
||||
/// <returns><see langword="true"/> if the specified objects' Id is equal to the current objects' Id, <see langword="false"/> otherwise.</returns>
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is Entity<TId> entity && Id.Equals(entity.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom implementation of the equality operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left operand of equality.</param>
|
||||
/// <param name="right">The right operand of equality.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="left"/> is equal to <paramref name="right"/>, <see langword="false"/> otherwise.</returns>
|
||||
public static bool operator ==(Entity<TId> left, Entity<TId> right)
|
||||
{
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom implementation of the inequality operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left operand of equality.</param>
|
||||
/// <param name="right">The right operand of equality.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="left"/> is not equal to <paramref name="right"/>, <see langword="false"/> otherwise.</returns>
|
||||
public static bool operator !=(Entity<TId> left, Entity<TId> right)
|
||||
{
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override of the default hash function.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for the current object.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id.GetHashCode();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#pragma warning restore CS8618
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Indicates whether the current object is equal to another object of the same type.
|
||||
/// </summary>
|
||||
/// <param name="other">An object to compare with this object.</param>
|
||||
/// <returns><see langword="true"/> if the current object is equal to the other parameter, <see langword="false"/> otherwise.</returns>
|
||||
public bool Equals(Entity<TId>? other)
|
||||
{
|
||||
return Equals((object?)other);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified objects' Id is equal to the current objects' Id.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object whose Id is compared with the current objects' Id.</param>
|
||||
/// <returns><see langword="true"/> if the specified objects' Id is equal to the current objects' Id, <see langword="false"/> otherwise.</returns>
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is Entity<TId> entity && Id.Equals(entity.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom implementation of the equality operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left operand of equality.</param>
|
||||
/// <param name="right">The right operand of equality.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="left"/> is equal to <paramref name="right"/>, <see langword="false"/> otherwise.</returns>
|
||||
public static bool operator ==(Entity<TId> left, Entity<TId> right)
|
||||
{
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom implementation of the inequality operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left operand of equality.</param>
|
||||
/// <param name="right">The right operand of equality.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="left"/> is not equal to <paramref name="right"/>, <see langword="false"/> otherwise.</returns>
|
||||
public static bool operator !=(Entity<TId> left, Entity<TId> right)
|
||||
{
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override of the default hash function.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for the current object.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id.GetHashCode();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -1,76 +1,76 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.Models.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for all domain Value Objects.
|
||||
/// </summary>
|
||||
public abstract class ValueObject : IEquatable<ValueObject>
|
||||
{
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public abstract IEnumerable<object?> GetEqualityComponents();
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the current object is equal to another object of the same type.
|
||||
/// </summary>
|
||||
/// <param name="other">An object to compare with this object.</param>
|
||||
/// <returns><see langword="true"/> if the current object is equal to the other parameter, <see langword="false"/> otherwise.</returns>
|
||||
public bool Equals(ValueObject? other)
|
||||
{
|
||||
return Equals((object?)other);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified object is equal to the current object.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current object.</param>
|
||||
/// <returns><see langword="true"/> if the specified object is equal to the current object, <see langword="false"/> otherwise.</returns>
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is null || obj.GetType() != GetType())
|
||||
return false;
|
||||
ValueObject valueObject = (ValueObject)obj;
|
||||
return GetEqualityComponents().SequenceEqual(valueObject.GetEqualityComponents());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom implementation of the equality operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left operand of equality.</param>
|
||||
/// <param name="right">The right operand of equality.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="left"/> is equal to <paramref name="right"/>, <see langword="false"/> otherwise.</returns>
|
||||
public static bool operator ==(ValueObject? left, ValueObject? right)
|
||||
{
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom implementation of the inequality operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left operand of equality.</param>
|
||||
/// <param name="right">The right operand of equality.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="left"/> is not equal to <paramref name="right"/>, <see langword="false"/> otherwise.</returns>
|
||||
public static bool operator !=(ValueObject? left, ValueObject? right)
|
||||
{
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override of the default hash function.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for the current object.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return GetEqualityComponents().Select(x => x?.GetHashCode() ?? 0)
|
||||
.Aggregate((x, y) => x ^ y);
|
||||
}
|
||||
#endregion
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.Models.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for all domain Value Objects.
|
||||
/// </summary>
|
||||
public abstract class ValueObject : IEquatable<ValueObject>
|
||||
{
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public abstract IEnumerable<object?> GetEqualityComponents();
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the current object is equal to another object of the same type.
|
||||
/// </summary>
|
||||
/// <param name="other">An object to compare with this object.</param>
|
||||
/// <returns><see langword="true"/> if the current object is equal to the other parameter, <see langword="false"/> otherwise.</returns>
|
||||
public bool Equals(ValueObject? other)
|
||||
{
|
||||
return Equals((object?)other);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified object is equal to the current object.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with the current object.</param>
|
||||
/// <returns><see langword="true"/> if the specified object is equal to the current object, <see langword="false"/> otherwise.</returns>
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is null || obj.GetType() != GetType())
|
||||
return false;
|
||||
ValueObject valueObject = (ValueObject)obj;
|
||||
return GetEqualityComponents().SequenceEqual(valueObject.GetEqualityComponents());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom implementation of the equality operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left operand of equality.</param>
|
||||
/// <param name="right">The right operand of equality.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="left"/> is equal to <paramref name="right"/>, <see langword="false"/> otherwise.</returns>
|
||||
public static bool operator ==(ValueObject? left, ValueObject? right)
|
||||
{
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom implementation of the inequality operator.
|
||||
/// </summary>
|
||||
/// <param name="left">The left operand of equality.</param>
|
||||
/// <param name="right">The right operand of equality.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="left"/> is not equal to <paramref name="right"/>, <see langword="false"/> otherwise.</returns>
|
||||
public static bool operator !=(ValueObject? left, ValueObject? right)
|
||||
{
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override of the default hash function.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for the current object.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return GetEqualityComponents().Select(x => x?.GetHashCode() ?? 0)
|
||||
.Aggregate((x, y) => x ^ y);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user