Adds first value objects of the domain

This commit is contained in:
BinaryAlley committed 2024-08-18 20:24:01 +03:00
1 parent 1e902e47dc
commit 12de2b27f0
19 files changed
+1207 -58

No files matched your search

@@ -1,58 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Common.Primitives;
#endregion
namespace Lumina.Domain.Common.Models.Metadata;
/// <summary>
/// Base class for all metadata-related value objects.
/// </summary>
public class BaseMetadata : ValueObject
{
#region ==================================================================== PROPERTIES =================================================================================
public string Title { get; }
public Optional<string> Description { get; }
public Optional<DateTime> ReleaseDate { get; }
public IReadOnlyList<string> Tags { get; }
public IReadOnlyList<string> Genres { get; }
public Optional<string> Language { get; }
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Overload C-tor.
/// </summary>
/// <param name="title">The title of the element to which this metadata object belongs to.</param>
/// <param name="releaseDate">The optional release date of the element to which this metadata object belongs to.</param>
/// <param name="description">The optional description of the element to which this metadata object belongs to.</param>
/// <param name="genres">The list of genres of the element to which this metadata object belongs to.</param>
/// <param name="tags">The list of tags of the element to which this metadata object belongs to.</param>
/// <param name="language">The optional language of the element to which this metadata object belongs to.</param>
/// <exception cref="ArgumentNullException"></exception>
public BaseMetadata(string title, Optional<DateTime> releaseDate, Optional<string> description, IEnumerable<string>? genres, IEnumerable<string>? tags, Optional<string> language)
{
Title = title ?? throw new ArgumentNullException(nameof(title));
ReleaseDate = releaseDate;
Description = description;
Genres = genres?.ToList().AsReadOnly() ?? new List<string>().AsReadOnly();
Tags = tags?.ToList().AsReadOnly() ?? new List<string>().AsReadOnly();
Language = language;
}
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <inheritdoc/>
public override IEnumerable<object> GetEqualityComponents()
{
yield return Title;
yield return ReleaseDate;
yield return Description;
foreach (var genre in Genres)
yield return genre;
foreach (var tag in Tags)
yield return tag;
yield return Language;
}
#endregion
}