mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21: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
@@ -0,0 +1,27 @@
|
||||
namespace Lumina.Domain.Common.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for the various sources of audio ratings.
|
||||
/// </summary>
|
||||
public enum AudioRatingSource
|
||||
{
|
||||
/// <summary>
|
||||
/// Ratings provided by users of the Lumina media library.
|
||||
/// </summary>
|
||||
User,
|
||||
|
||||
/// <summary>
|
||||
/// Ratings sourced from MusicBrainz, an open music encyclopedia that collects music metadata.
|
||||
/// </summary>
|
||||
MusicBrainz,
|
||||
|
||||
/// <summary>
|
||||
/// Ratings obtained from Discogs, a database and marketplace for music recordings.
|
||||
/// </summary>
|
||||
Discogs,
|
||||
|
||||
/// <summary>
|
||||
/// Ratings from Last.fm, a music website that provides music recommendations based on user listening habits.
|
||||
/// </summary>
|
||||
LastFm,
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
namespace Lumina.Domain.Common.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for various book formats.
|
||||
/// </summary>
|
||||
public enum BookFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// A book bound with rigid protective covers (typically cardboard covered with cloth, heavy paper, or leather).
|
||||
/// </summary>
|
||||
Hardcover,
|
||||
|
||||
/// <summary>
|
||||
/// A book with a flexible paper cover, typically less durable than a hardcover.
|
||||
/// </summary>
|
||||
Paperback,
|
||||
|
||||
/// <summary>
|
||||
/// A small, usually non-illustrated, and inexpensive paperback book.
|
||||
/// </summary>
|
||||
MassMarketPaperback,
|
||||
|
||||
/// <summary>
|
||||
/// A larger, often higher-quality paperback book, typically used for literary fiction and nonfiction.
|
||||
/// </summary>
|
||||
TradePaperback,
|
||||
|
||||
/// <summary>
|
||||
/// A digital version of a book that can be read on electronic devices.
|
||||
/// </summary>
|
||||
eBook,
|
||||
|
||||
/// <summary>
|
||||
/// A recorded audio version of a book, either on physical media or as a digital file.
|
||||
/// </summary>
|
||||
Audiobook,
|
||||
|
||||
/// <summary>
|
||||
/// A book printed with larger text for easier reading, often used by those with visual impairments.
|
||||
/// </summary>
|
||||
LargePrint,
|
||||
|
||||
/// <summary>
|
||||
/// A sturdy book with thick cardboard pages, typically designed for young children.
|
||||
/// </summary>
|
||||
BoardBook,
|
||||
|
||||
/// <summary>
|
||||
/// A book bound with a spiral wire or plastic coil, allowing it to lay flat when open.
|
||||
/// </summary>
|
||||
SpiralBound,
|
||||
|
||||
/// <summary>
|
||||
/// A reinforced binding designed for frequent use, often used in schools and public libraries.
|
||||
/// </summary>
|
||||
LibraryBinding,
|
||||
|
||||
/// <summary>
|
||||
/// A book bound in leather, often used for luxury or collector's editions.
|
||||
/// </summary>
|
||||
LeatherBound,
|
||||
|
||||
/// <summary>
|
||||
/// A book with three-dimensional paper engineering, creating pop-up or movable parts.
|
||||
/// </summary>
|
||||
PopupBook
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace Lumina.Domain.Common.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for the various sources of book ratings.
|
||||
/// </summary>
|
||||
public enum BookRatingSource
|
||||
{
|
||||
/// <summary>
|
||||
/// Ratings provided by users of the Lumina system.
|
||||
/// </summary>
|
||||
User,
|
||||
|
||||
/// <summary>
|
||||
/// Ratings sourced from Goodreads, a social network for book readers that provides book recommendations and reviews.
|
||||
/// </summary>
|
||||
Goodreads,
|
||||
|
||||
/// <summary>
|
||||
/// Ratings obtained from Amazon, an e-commerce platform that includes customer reviews and ratings for books.
|
||||
/// </summary>
|
||||
Amazon,
|
||||
|
||||
/// <summary>
|
||||
/// Ratings from Google Books, a service that searches the full text of books and magazines that Google has scanned and converted to text.
|
||||
/// </summary>
|
||||
GoogleBooks,
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace Lumina.Domain.Common.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for the different ISBN (International Standard Book Number) formats.
|
||||
/// </summary>
|
||||
public enum IsbnFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// The 10-digit ISBN format used for books published before 2007.
|
||||
/// Example: 0-306-40615-2
|
||||
/// </summary>
|
||||
Isbn10,
|
||||
|
||||
/// <summary>
|
||||
/// The 13-digit ISBN format introduced in 2007, now the standard for all new books.
|
||||
/// Example: 978-0-306-40615-7
|
||||
/// </summary>
|
||||
Isbn13
|
||||
}
|
||||
@@ -1,12 +1,27 @@
|
||||
namespace Lumina.Domain.Common.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for the roles of media contributors.
|
||||
/// Enumeration for the various roles of media contributors across different types of media.
|
||||
/// </summary>
|
||||
public enum MediaContributorRole
|
||||
{
|
||||
/// <summary>
|
||||
/// A person who portrays a character in a performance, typically in films, television shows, or theater productions.
|
||||
/// </summary>
|
||||
Actor,
|
||||
|
||||
/// <summary>
|
||||
/// The person responsible for overseeing and directing the production of a film, play, television show, or other performing art.
|
||||
/// </summary>
|
||||
Director,
|
||||
|
||||
/// <summary>
|
||||
/// A person who uses their voice to produce musical sounds, typically with a melody and often with lyrics in songs.
|
||||
/// </summary>
|
||||
Singer,
|
||||
|
||||
/// <summary>
|
||||
/// The creator or originator of a written work, such as a book, article, or other literary piece.
|
||||
/// </summary>
|
||||
Author
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace Lumina.Domain.Common.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for the ratings sources.
|
||||
/// </summary>
|
||||
public enum RatingSource
|
||||
{
|
||||
User,
|
||||
Imdb,
|
||||
TheTvDb,
|
||||
TheMovieDb,
|
||||
RottenTomatoes,
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace Lumina.Domain.Common.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration for the various sources of video ratings.
|
||||
/// </summary>
|
||||
public enum VideoRatingSource
|
||||
{
|
||||
/// <summary>
|
||||
/// Ratings provided by users of the Lumina media library.
|
||||
/// </summary>
|
||||
User,
|
||||
|
||||
/// <summary>
|
||||
/// Ratings sourced from IMDb (Internet Movie Database), an online database of information related to films, TV programs, and video games.
|
||||
/// </summary>
|
||||
Imdb,
|
||||
|
||||
/// <summary>
|
||||
/// Ratings obtained from TheTVDB, an open database for television shows, including episode information and user ratings.
|
||||
/// </summary>
|
||||
TheTvDb,
|
||||
|
||||
/// <summary>
|
||||
/// Ratings from The Movie Database (TMDb), a community-built movie and TV database.
|
||||
/// </summary>
|
||||
TheMovieDb,
|
||||
|
||||
/// <summary>
|
||||
/// Ratings from Rotten Tomatoes, a review-aggregation website for film and television.
|
||||
/// </summary>
|
||||
RottenTomatoes,
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.Errors;
|
||||
|
||||
/// <summary>
|
||||
/// Written content error types.
|
||||
/// </summary>
|
||||
public static partial class Errors
|
||||
{
|
||||
public static class WrittenContent
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public static Error IsbnCannotBeEmpty => Error.Validation(nameof(IsbnCannotBeEmpty));
|
||||
public static Error InvalidIsbn10Format => Error.Validation(nameof(InvalidIsbn10Format));
|
||||
public static Error InvalidIsbn13Format => Error.Validation(nameof(InvalidIsbn13Format));
|
||||
public static Error UnknownIsbnFormat => Error.Unexpected(nameof(UnknownIsbnFormat));
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,20 @@
|
||||
/// 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>
|
||||
/// <typeparam name="TIdType">The type of the unique identifier for the Aggregate Root. It should be a non-nullable type.</typeparam>
|
||||
public abstract class AggregateRoot<TId, TIdType> : Entity<TId> where TId : notnull, AggregateRootId<TIdType>
|
||||
where TIdType : notnull
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the unique identifier of the Aggregate Root.
|
||||
/// </summary>
|
||||
public new AggregateRootId<TIdType> Id { get; protected set; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// Initializes a new instance of the <see cref="AggregateRoot{TId, TIdType}"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The id of the entity.</param>
|
||||
protected AggregateRoot(TId id) : base(id)
|
||||
@@ -22,6 +26,9 @@ public abstract class AggregateRoot<TId, TIdType> : Entity<TId> where TId : notn
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AggregateRoot{TId, TIdType}"/> class.
|
||||
/// </summary>
|
||||
protected AggregateRoot() // only needed during reflection
|
||||
{
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ namespace Lumina.Domain.Common.Models.Core;
|
||||
public abstract class AggregateRootId<TId> : ValueObject where TId : notnull
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the unique identifier of the Aggregate Root.
|
||||
/// </summary>
|
||||
public abstract TId Value { get; protected set; }
|
||||
#endregion
|
||||
}
|
||||
@@ -7,12 +7,15 @@
|
||||
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; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// 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)
|
||||
@@ -21,6 +24,9 @@ public abstract class Entity<TId> : IEquatable<Entity<TId>> where TId : notnull
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Entity{TId}"/> class.
|
||||
/// </summary>
|
||||
protected Entity() // only needed during reflection
|
||||
{
|
||||
|
||||
|
||||
@@ -12,7 +12,14 @@ public readonly struct Optional<T>
|
||||
#endregion
|
||||
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this structure has a value.
|
||||
/// </summary>
|
||||
public bool HasValue { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value represented by this structure.
|
||||
/// </summary>
|
||||
public T Value
|
||||
{
|
||||
get
|
||||
@@ -24,7 +31,7 @@ public readonly struct Optional<T>
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// Initializes a new instance of the <see cref="Optional{T}"/> structure.
|
||||
/// </summary>
|
||||
/// <param name="value">The value represented by this structure.</param>
|
||||
public Optional(T value)
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Enums;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.ValueObjects.Media;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for a contributor of a media element.
|
||||
/// </summary>
|
||||
public sealed class MediaContributor : ValueObject
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public PersonId PersonId { get; }
|
||||
public Optional<MediaContributorRole> Role { get; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// </summary>
|
||||
/// <param name="personId">The id of the person represented by this object.</param>
|
||||
/// <param name="role">The role of the person represented by this object.</param>
|
||||
private MediaContributor(PersonId personId, Optional<MediaContributorRole> role)
|
||||
{
|
||||
Role = role;
|
||||
PersonId = personId;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="MediaContributor"/>.
|
||||
/// </summary>
|
||||
/// <param name="personId">The id of the person represented by this object.</param>
|
||||
/// <param name="role">The role of the person represented by this object.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{T}"/> containing either a successfully created <see cref="MediaContributor"/> or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<MediaContributor> Create(PersonId personId, Optional<MediaContributorRole> role)
|
||||
{
|
||||
return new MediaContributor(personId, role);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return PersonId;
|
||||
yield return Role;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.ValueObjects.Media;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the Id of a person.
|
||||
/// </summary>
|
||||
public sealed class PersonId : ValueObject
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public Guid Value { get; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
private PersonId(Guid value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="PersonId"/>.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="PersonId"/> instance.</returns>
|
||||
public static PersonId CreateUnique()
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new PersonId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="PersonId"/> from <paramref name="value"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value used to create the <see cref="PersonId"/> instance.</param>
|
||||
/// <returns>The created <see cref="PersonId"/> instance.</returns>
|
||||
public static PersonId Create(Guid value)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new PersonId(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -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