mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 15:11:10 +00:00
Continues core Domain structure modeling
This commit is contained in:
1 parent
c39652066e
commit
50c15cf889
54 files changed
+2318
-159
No files matched your search
@@ -1,4 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
#endregion
|
||||
@@ -8,53 +9,65 @@ namespace Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
/// <summary>
|
||||
/// Base template for all metadata-related value objects.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Title}")]
|
||||
public abstract class BaseMetadata : ValueObject
|
||||
{
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
private readonly List<Tag> _tags;
|
||||
private readonly List<Genre> _genres;
|
||||
#endregion
|
||||
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the title of the media item.
|
||||
/// </summary>
|
||||
public string Title { get; }
|
||||
public string Title { get; private set;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the original title of the media item.
|
||||
/// </summary>
|
||||
public Optional<string> OriginalTitle { get; }
|
||||
public Optional<string> OriginalTitle { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional description of the media item.
|
||||
/// </summary>
|
||||
public Optional<string> Description { get; }
|
||||
public Optional<string> Description { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the release information of the media item.
|
||||
/// </summary>
|
||||
public ReleaseInfo ReleaseInfo { get; }
|
||||
public ReleaseInfo ReleaseInfo { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of tags associated with the media item.
|
||||
/// </summary>
|
||||
public IReadOnlyList<Tag> Tags { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of genres associated with the media item.
|
||||
/// </summary>
|
||||
public IReadOnlyList<Genre> Genres { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional language of the media item.
|
||||
/// </summary>
|
||||
public Optional<LanguageInfo> Language { get; }
|
||||
public Optional<LanguageInfo> Language { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional original language of the media item.
|
||||
/// </summary>
|
||||
public Optional<LanguageInfo> OriginalLanguage { get; }
|
||||
public Optional<LanguageInfo> OriginalLanguage { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of tags associated with the media item.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<Tag> Tags
|
||||
{
|
||||
get { return _tags.AsReadOnly(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of genres associated with the media item.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<Genre> Genres
|
||||
{
|
||||
get { return _genres.AsReadOnly(); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// Initializes a new instance of the <see cref="BaseMetadata"/> class.
|
||||
/// </summary>
|
||||
/// <param name="title">The title of the element to which this metadata object belongs to.</param>
|
||||
/// <param name="originalTitle">The optional original title of the element to which this metadata object belongs to.</param>
|
||||
@@ -65,15 +78,22 @@ public abstract class BaseMetadata : ValueObject
|
||||
/// <param name="language">The optional language of the element to which this metadata object belongs to.</param>
|
||||
/// <param name="originalLanguage">The optional original language of the element to which this metadata object belongs to.</param>
|
||||
/// <exception cref="ArgumentNullException">Thrown when the <see cref="title"/> value is <see langword="null"/></exception>
|
||||
protected BaseMetadata(string title, Optional<string> originalTitle, ReleaseInfo releaseInfo, Optional<string> description,
|
||||
IEnumerable<Genre>? genres, IEnumerable<Tag>? tags, Optional<LanguageInfo> language, Optional<LanguageInfo> originalLanguage)
|
||||
protected BaseMetadata(
|
||||
string title,
|
||||
Optional<string> originalTitle,
|
||||
ReleaseInfo releaseInfo,
|
||||
Optional<string> description,
|
||||
List<Genre> genres,
|
||||
List<Tag> tags,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> originalLanguage)
|
||||
{
|
||||
Title = title ?? throw new ArgumentNullException(nameof(title));
|
||||
OriginalTitle = originalTitle;
|
||||
ReleaseInfo = releaseInfo;
|
||||
Description = description;
|
||||
Genres = genres?.ToList().AsReadOnly() ?? new List<Genre>().AsReadOnly();
|
||||
Tags = tags?.ToList().AsReadOnly() ?? new List<Tag>().AsReadOnly();
|
||||
_genres = genres;
|
||||
_tags = tags;
|
||||
Language = language;
|
||||
OriginalLanguage = originalLanguage;
|
||||
}
|
||||
@@ -87,9 +107,9 @@ public abstract class BaseMetadata : ValueObject
|
||||
yield return OriginalTitle;
|
||||
yield return ReleaseInfo;
|
||||
yield return Description;
|
||||
foreach (var genre in Genres)
|
||||
foreach (var genre in _genres)
|
||||
yield return genre;
|
||||
foreach (var tag in Tags)
|
||||
foreach (var tag in _tags)
|
||||
yield return tag;
|
||||
yield return Language;
|
||||
yield return OriginalLanguage;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Genre : ValueObject
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// Initializes a new instance of the <see cref="Genre"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The value representing this object.</param>
|
||||
private Genre(string name)
|
||||
@@ -32,7 +32,7 @@ public class Genre : ValueObject
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="Genre"/>.
|
||||
/// Creates a new instance of the <see cref="Genre"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The value of the genre.</param>
|
||||
/// <returns>
|
||||
|
||||
@@ -33,7 +33,7 @@ public class LanguageInfo : ValueObject
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// Initializes a new instance of the <see cref="LanguageInfo"/> class.
|
||||
/// </summary>
|
||||
/// <param name="languageCode">The ISO 639-1 two-letter language code.</param>
|
||||
/// <param name="languageName">The full name of the language in English.</param>
|
||||
@@ -50,7 +50,7 @@ public class LanguageInfo : ValueObject
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="LanguageInfo"/>.
|
||||
/// Creates a new instance of the <see cref="LanguageInfo"/> class.
|
||||
/// </summary>
|
||||
/// <param name="languageCode">The ISO 639-1 two-letter language code.</param>
|
||||
/// <param name="languageName">The full name of the language in English.</param>
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Rating : ValueObject
|
||||
/// <summary>
|
||||
/// Gets the optional source of the rating (e.g., "IMDB", "Rotten Tomatoes").
|
||||
/// </summary>
|
||||
public Optional<RatingSource> Source { get; }
|
||||
public Optional<VideoRatingSource> Source { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional number of votes or reviews this rating is based on.
|
||||
@@ -38,13 +38,13 @@ public class Rating : ValueObject
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// Initializes a new instance of the <see cref="Rating"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The numeric value of the rating.</param>
|
||||
/// <param name="maxValue">The maximum possible rating value.</param>
|
||||
/// <param name="source">The optional source of the rating.</param>
|
||||
/// <param name="voteCount">The optional number of votes or reviews.</param>
|
||||
private Rating(decimal value, decimal maxValue, Optional<RatingSource> source = default, Optional<int> voteCount = default)
|
||||
private Rating(decimal value, decimal maxValue, Optional<VideoRatingSource> source, Optional<int> voteCount)
|
||||
{
|
||||
Value = value;
|
||||
MaxValue = maxValue;
|
||||
@@ -55,7 +55,7 @@ public class Rating : ValueObject
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="Rating"/>.
|
||||
/// Creates a new instance of the <see cref="Rating"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The numeric value of the rating.</param>
|
||||
/// <param name="maxValue">The maximum possible rating value.</param>
|
||||
@@ -64,7 +64,7 @@ public class Rating : ValueObject
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{T}"/> containing either a successfully created <see cref="Rating"/> or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<Rating> Create(decimal value, decimal maxValue, Optional<RatingSource> source = default, Optional<int> voteCount = default)
|
||||
public static ErrorOr<Rating> Create(decimal value, decimal maxValue, Optional<VideoRatingSource> source, Optional<int> voteCount)
|
||||
{
|
||||
if (maxValue < 0 || value < 0)
|
||||
return Errors.Errors.Metadata.RatingMustBePositive;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ReleaseInfo : ValueObject
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// Initializes a new instance of the <see cref="ReleaseInfo"/> class.
|
||||
/// </summary>
|
||||
/// <param name="originalReleaseDate">The optional original release date of the media item.</param>
|
||||
/// <param name="originalReleaseYear">The optional original release year of the media item.</param>
|
||||
@@ -56,8 +56,13 @@ public class ReleaseInfo : ValueObject
|
||||
/// <param name="reReleaseYear">The optional re-release year of the media item.</param>
|
||||
/// <param name="releaseCountry">The optional country or region of release.</param>
|
||||
/// <param name="releaseVersion">The optional release version or edition.</param>
|
||||
private ReleaseInfo(Optional<DateOnly> originalReleaseDate, Optional<int> originalReleaseYear,
|
||||
Optional<DateOnly> reReleaseDate, Optional<int> reReleaseYear, Optional<string> releaseCountry, Optional<string> releaseVersion)
|
||||
private ReleaseInfo(
|
||||
Optional<DateOnly> originalReleaseDate,
|
||||
Optional<int> originalReleaseYear,
|
||||
Optional<DateOnly> reReleaseDate,
|
||||
Optional<int> reReleaseYear,
|
||||
Optional<string> releaseCountry,
|
||||
Optional<string> releaseVersion)
|
||||
{
|
||||
OriginalReleaseDate = originalReleaseDate;
|
||||
OriginalReleaseYear = originalReleaseYear;
|
||||
@@ -70,7 +75,7 @@ public class ReleaseInfo : ValueObject
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="ReleaseInfo"/>.
|
||||
/// Creates a new instance of the <see cref="ReleaseInfo"/> class.
|
||||
/// </summary>
|
||||
/// <param name="originalReleaseDate">The optional original release date of the media item.</param>
|
||||
/// <param name="originalReleaseYear">The optional original release year of the media item.</param>
|
||||
@@ -81,8 +86,13 @@ public class ReleaseInfo : ValueObject
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{T}"/> containing either a successfully created <see cref="ReleaseInfo"/> or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<ReleaseInfo> Create(Optional<DateOnly> originalReleaseDate, Optional<int> originalReleaseYear,
|
||||
Optional<DateOnly> reReleaseDate, Optional<int> reReleaseYear, Optional<string> releaseCountry, Optional<string> releaseVersion)
|
||||
public static ErrorOr<ReleaseInfo> Create(
|
||||
Optional<DateOnly> originalReleaseDate,
|
||||
Optional<int> originalReleaseYear,
|
||||
Optional<DateOnly> reReleaseDate,
|
||||
Optional<int> reReleaseYear,
|
||||
Optional<string> releaseCountry,
|
||||
Optional<string> releaseVersion)
|
||||
{
|
||||
if (originalReleaseDate.HasValue && originalReleaseYear.HasValue && originalReleaseDate.Value.Year != originalReleaseYear.Value)
|
||||
return Errors.Errors.Metadata.OriginalReleaseDateAndYearMustMatch;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Tag : ValueObject
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// Initializes a new instance of the <see cref="Tag"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The value representing this object.</param>
|
||||
private Tag(string name)
|
||||
@@ -32,7 +32,7 @@ public class Tag : ValueObject
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="Tag"/>.
|
||||
/// Creates a new instance of the <see cref="Tag"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The value of the tag.</param>
|
||||
/// <returns>
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Media;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the rating of a media element.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Value}/{MaxValue}")]
|
||||
public class VideoMetadata : BaseMetadata
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the duration of the video in seconds.
|
||||
/// </summary>
|
||||
public int DurationInSeconds { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the resolution of the video.
|
||||
/// </summary>
|
||||
public string Resolution { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the frame rate of the video.
|
||||
/// </summary>
|
||||
public Optional<float> FrameRate { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the video codec used.
|
||||
/// </summary>
|
||||
public Optional<string> VideoCodec { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the audio codec used.
|
||||
/// </summary>
|
||||
public Optional<string> AudioCodec { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of actors starring in this video.
|
||||
/// </summary>
|
||||
public IReadOnlyList<MediaContributor> Contributors { get; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// </summary>
|
||||
/// <param name="title">The title of the video.</param>
|
||||
/// <param name="originalTitle">The optional original title of the video.</param>
|
||||
/// <param name="durationInSeconds">The duration of the video in seconds.</param>
|
||||
/// <param name="resolution">The resolution of the video.</param>
|
||||
/// <param name="release">The release information of the video.</param>
|
||||
/// <param name="description">The optional description of the video.</param>
|
||||
/// <param name="language">The language of the video.</param>
|
||||
/// <param name="originalLanguage">The optional original language of the video.</param>
|
||||
/// <param name="frameRate">The optional frame rate of the video.</param>
|
||||
/// <param name="videoCodec">The optional video codec used.</param>
|
||||
/// <param name="audioCodec">The optional audio codec used.</param>
|
||||
/// <param name="genres">The genres of the video.</param>
|
||||
/// <param name="tags">The tags associated with the video.</param>
|
||||
/// <param name="contributors">The list of contributors for this video.</param>
|
||||
private VideoMetadata(string title, Optional<string> originalTitle, int durationInSeconds, string resolution, ReleaseInfo release, Optional<string> description,
|
||||
Optional<LanguageInfo> language, Optional<LanguageInfo> originalLanguage, Optional<float> frameRate, Optional<string> videoCodec, Optional<string> audioCodec,
|
||||
IEnumerable<Genre>? genres = null, IEnumerable<Tag>? tags = null, IEnumerable<MediaContributor>? contributors = null)
|
||||
: base(title, originalTitle, release, description, genres, tags, language, originalLanguage)
|
||||
{
|
||||
DurationInSeconds = durationInSeconds;
|
||||
Resolution = resolution ?? throw new ArgumentNullException(nameof(resolution));
|
||||
FrameRate = frameRate;
|
||||
VideoCodec = videoCodec;
|
||||
AudioCodec = audioCodec;
|
||||
Contributors = contributors?.ToList().AsReadOnly() ?? new List<MediaContributor>().AsReadOnly();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="VideoMetadata"/>.
|
||||
/// </summary>
|
||||
/// <param name="title">The title of the video.</param>
|
||||
/// <param name="originalTitle">The optional original title of the video.</param>
|
||||
/// <param name="durationInSeconds">The duration of the video in seconds.</param>
|
||||
/// <param name="resolution">The resolution of the video.</param>
|
||||
/// <param name="release">The release information of the video.</param>
|
||||
/// <param name="description">The optional description of the video.</param>
|
||||
/// <param name="language">The language of the video.</param>
|
||||
/// <param name="originalLanguage">The optional original language of the video.</param>
|
||||
/// <param name="frameRate">The optional frame rate of the video.</param>
|
||||
/// <param name="videoCodec">The optional video codec used.</param>
|
||||
/// <param name="audioCodec">The optional audio codec used.</param>
|
||||
/// <param name="genres">The genres of the video.</param>
|
||||
/// <param name="tags">The tags associated with the video.</param>
|
||||
/// <param name="contributors">The list of contributors for this video.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{T}"/> containing either a successfully created <see cref="VideoMetadata"/> or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<VideoMetadata> Create(string title, Optional<string> originalTitle, int durationInSeconds, string resolution, ReleaseInfo release, Optional<string> description,
|
||||
Optional<LanguageInfo> language, Optional<LanguageInfo> originalLanguage, Optional<float> frameRate, Optional<string> videoCodec, Optional<string> audioCodec,
|
||||
IEnumerable<Genre>? genres = null, IEnumerable<Tag>? tags = null, IEnumerable<MediaContributor>? contributors = null)
|
||||
{
|
||||
return new VideoMetadata(title, originalTitle, durationInSeconds, resolution, release, description,
|
||||
language, originalLanguage, frameRate, videoCodec, audioCodec, genres, tags, contributors);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
foreach (var component in base.GetEqualityComponents())
|
||||
yield return component;
|
||||
yield return DurationInSeconds;
|
||||
yield return Resolution;
|
||||
yield return FrameRate;
|
||||
yield return VideoCodec;
|
||||
yield return AudioCodec;
|
||||
foreach (var contributor in Contributors)
|
||||
yield return contributor;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user