#region ========================================================================= USING ===================================================================================== using System.Diagnostics; using Lumina.Domain.Common.Models.Core; using Lumina.Domain.Common.Primitives; #endregion namespace Lumina.Domain.Common.ValueObjects.Metadata; /// /// Base template for all metadata-related value objects. /// [DebuggerDisplay("{Title}")] public abstract class BaseMetadata : ValueObject { #region ================================================================== FIELD MEMBERS ================================================================================ private readonly List _tags; private readonly List _genres; #endregion #region ==================================================================== PROPERTIES ================================================================================= /// /// Gets the title of the media item. /// public string Title { get; private set;} /// /// Gets the original title of the media item. /// public Optional OriginalTitle { get; private set; } /// /// Gets the optional description of the media item. /// public Optional Description { get; private set; } /// /// Gets the release information of the media item. /// public ReleaseInfo ReleaseInfo { get; private set; } /// /// Gets the optional language of the media item. /// public Optional Language { get; private set; } /// /// Gets the optional original language of the media item. /// public Optional OriginalLanguage { get; private set; } /// /// Gets the list of tags associated with the media item. /// public IReadOnlyCollection Tags { get { return _tags.AsReadOnly(); } } /// /// Gets the list of genres associated with the media item. /// public IReadOnlyCollection Genres { get { return _genres.AsReadOnly(); } } #endregion #region ====================================================================== CTOR ===================================================================================== /// /// Initializes a new instance of the class. /// /// The title of the element to which this metadata object belongs to. /// The optional original title of the element to which this metadata object belongs to. /// The optional release information of the media item. /// The optional description of the element to which this metadata object belongs to. /// The list of genres of the element to which this metadata object belongs to. /// The list of tags of the element to which this metadata object belongs to. /// The optional language of the element to which this metadata object belongs to. /// The optional original language of the element to which this metadata object belongs to. /// Thrown when the value is protected BaseMetadata( string title, Optional originalTitle, ReleaseInfo releaseInfo, Optional description, List genres, List tags, Optional language, Optional originalLanguage) { Title = title ?? throw new ArgumentNullException(nameof(title)); OriginalTitle = originalTitle; ReleaseInfo = releaseInfo; Description = description; _genres = genres; _tags = tags; Language = language; OriginalLanguage = originalLanguage; } #endregion #region ===================================================================== METHODS =================================================================================== /// public override IEnumerable GetEqualityComponents() { yield return Title; yield return OriginalTitle; yield return ReleaseInfo; yield return Description; foreach (var genre in _genres) yield return genre; foreach (var tag in _tags) yield return tag; yield return Language; yield return OriginalLanguage; } #endregion }