mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +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,71 @@
|
||||
- [Lumina Domain](#lumina-domain)
|
||||
- [Video Library Aggregate](#video-library-aggregate)
|
||||
- [Movie](#movie)
|
||||
|
||||
# [Lumina Domain](#lumina-domain)
|
||||
|
||||
## [Video Library Aggregate](#video-library-aggregate)
|
||||
|
||||
### [Movie](#movie)
|
||||
|
||||
```csharp
|
||||
class Movie
|
||||
{
|
||||
ErrorOr<Movie> Create(MovieId id, VideoMetadata metadata, List<MediaContributorId> contributors);
|
||||
}
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"id": { "value": "00000000-0000-0000-0000-000000000000" },
|
||||
"metadata": {
|
||||
"title": "The Lord of the Rings - The Fellowship of the Ring",
|
||||
"originalTitle": "The Lord of the Rings - The Fellowship of the Ring",
|
||||
"description": "The greatest fantasy movie ever made",
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "2001-12-19",
|
||||
"originalReleaseYear": 2001,
|
||||
"reReleaseDate": "2024-06-08",
|
||||
"reReleaseYear": 2024,
|
||||
"releaseCountry": "us",
|
||||
"releaseVersion": "Director's Cut"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"tags": [
|
||||
{ "name": "epic quest" },
|
||||
{ "name": "friendship" },
|
||||
{ "name": "middle-earth" }
|
||||
],
|
||||
"genres": [
|
||||
{ "name": "fantasy" },
|
||||
{ "name": "adventure" },
|
||||
{ "name": "action" }
|
||||
],
|
||||
"durationInSeconds": 10680,
|
||||
"resolution": "3840x2160",
|
||||
"frameRate": 29.97,
|
||||
"videoCodec": "h.265/hevc",
|
||||
"audioCodec": "FLAC"
|
||||
},
|
||||
"contributors": [
|
||||
{ "value": "00000000-0000-0000-0000-000000000000" }
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 9.8,
|
||||
"maxValue": 10.0,
|
||||
"source": "TheMovieDb",
|
||||
"voteCount": 1547036
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,196 @@
|
||||
- [Lumina Domain](#lumina-domain)
|
||||
- [Written Content Library Aggregate](#written-content-library-aggregate)
|
||||
- [Book](#book)
|
||||
|
||||
# [Lumina Domain](#lumina-domain)
|
||||
|
||||
## [Written Content Library Aggregate](#written-content-library-aggregate)
|
||||
|
||||
### [Book](#book)
|
||||
|
||||
```csharp
|
||||
class Book
|
||||
{
|
||||
ErrorOr<Book> Create(
|
||||
WrittenContentMetadata metadata,
|
||||
BookFormat format,
|
||||
Optional<string> edition,
|
||||
Optional<int> volumeNumber,
|
||||
Optional<string> series,
|
||||
Optional<string> asin,
|
||||
Optional<string> goodreadsId,
|
||||
Optional<string> lccn,
|
||||
Optional<string> oclcNumber,
|
||||
Optional<string> openLibraryId,
|
||||
Optional<string> libraryThingId,
|
||||
Optional<string> googleBooksId,
|
||||
Optional<string> barnesAndNobleId,
|
||||
Optional<string> koboId,
|
||||
Optional<string> appleBooksId,
|
||||
List<Isbn> isbns,
|
||||
List<MediaContributorId> contributors,
|
||||
List<Rating> ratings);
|
||||
}
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"id": {
|
||||
"value": "00000000-0000-0000-0000-000000000000"
|
||||
},
|
||||
"metadata": {
|
||||
"title": "The Lord of the Rings: The Fellowship of the Ring",
|
||||
"originalTitle": "The Fellowship of the Ring",
|
||||
"description": "The first part of J.R.R. Tolkien's epic adventure The Lord of the Rings. In a sleepy village in the Shire, young Frodo Baggins finds himself faced with an immense task, as his elderly cousin Bilbo entrusts the Ring to his care. Frodo must leave his home and make a perilous journey across Middle-earth to the Cracks of Doom, there to destroy the Ring and foil the Dark Lord in his evil purpose.",
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1954-07-29",
|
||||
"originalReleaseYear": 1954,
|
||||
"reReleaseDate": "2001-09-06",
|
||||
"reReleaseYear": 2001,
|
||||
"releaseCountry": "uk",
|
||||
"releaseVersion": "50th Anniversary Edition"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"tags": [
|
||||
{ "name": "epic fantasy" },
|
||||
{ "name": "quest" },
|
||||
{ "name": "middle-earth" }
|
||||
],
|
||||
"genres": [
|
||||
{ "name": "fantasy" },
|
||||
{ "name": "adventure" },
|
||||
{ "name": "classic" }
|
||||
],
|
||||
"publisher": "Houghton Mifflin",
|
||||
"pageCount": 398
|
||||
},
|
||||
"format": "Paperback",
|
||||
"edition": "50th Anniversary Edition",
|
||||
"volumeNumber": 1,
|
||||
"series": "The Lord of the Rings",
|
||||
"asin": "B007978NPG",
|
||||
"goodreadsId": "3",
|
||||
"lccn": "2001025199",
|
||||
"oclcNumber": "48494995",
|
||||
"openLibraryId": "OL7603910M",
|
||||
"libraryThingId": "3203347",
|
||||
"googleBooksId": "aWZzLPhY4o0C",
|
||||
"barnesAndNobleId": "1100307790",
|
||||
"koboId": "the-fellowship-of-the-ring",
|
||||
"appleBooksId": "id395211",
|
||||
"isbns": [
|
||||
{
|
||||
{
|
||||
"value": "0395272238",
|
||||
"format": "Isbn10"
|
||||
},
|
||||
{
|
||||
"value": "9780395272237",
|
||||
"format": "Isbn13"
|
||||
}
|
||||
}
|
||||
],
|
||||
"contributors": [
|
||||
{
|
||||
"value": "00000000-0000-0000-0000-000000000000",
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"source": "Goodreads",
|
||||
"value": 4.36,
|
||||
"maxValue": 5,
|
||||
"voteCount": 2345678
|
||||
},
|
||||
{
|
||||
"source": "Amazon",
|
||||
"value": 4.7,
|
||||
"maxValue": 5,
|
||||
"voteCount": 87654
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"id": {
|
||||
"value": "00000000-0000-0000-0000-000000000000"
|
||||
},
|
||||
"metadata": {
|
||||
"title": "The Lord of the Rings - The Fellowship of the Ring",
|
||||
"originalTitle": "The Lord of the Rings - The Fellowship of the Ring",
|
||||
"description": "The greatest fantasy movie ever made",
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "2001-12-19",
|
||||
"originalReleaseYear": 2001,
|
||||
"reReleaseDate": "2024-06-08",
|
||||
"reReleaseYear": 2024,
|
||||
"releaseCountry": "us",
|
||||
"releaseVersion": "Director's Cut"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"tags": [
|
||||
{ "name": "epic quest" },
|
||||
{ "name": "friendship" },
|
||||
{ "name": "middle-earth" }
|
||||
],
|
||||
"genres": [
|
||||
{ "name": "fantasy" },
|
||||
{ "name": "adventure" },
|
||||
{ "name": "action" }
|
||||
],
|
||||
"publisher": "Allen & Unwin",
|
||||
"pageCount": 432
|
||||
},
|
||||
"format": "Hardcover",
|
||||
"edition": "First Edition",
|
||||
"volumeNumber": 1,
|
||||
"series": "The Lord of the Rings",
|
||||
"isbn": "978-0261103573",
|
||||
"asin": "B00GO9BZLU",
|
||||
"goodreadsId": "3",
|
||||
"lccn": "2001271784",
|
||||
"oclcNumber": "46516480",
|
||||
"openLibraryId": "OL7603610M",
|
||||
"libraryThingId": "3203347",
|
||||
"googleBooksId": "aWZzLPhY4o0C",
|
||||
"barnesAndNobleId": "1100307790",
|
||||
"koboId": "lord-of-the-rings-fellowship-of-the-ring",
|
||||
"appleBooksId": "id395211",
|
||||
"contributors": [
|
||||
{
|
||||
"value": "00000000-0000-0000-0000-000000000000",
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"source": "Goodreads",
|
||||
"value": 4.36,
|
||||
"maxValue": 5,
|
||||
"voteCount": 2345678
|
||||
},
|
||||
{
|
||||
"source": "Amazon",
|
||||
"value": 4.7,
|
||||
"maxValue": 5,
|
||||
"voteCount": 87654
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -121,6 +121,27 @@
|
||||
- SupplementaryContentLibrary (root: SupplementaryContentLibrary, entities: SubtitleFile, Lyrics, LanguageTrack)
|
||||
- FileManagement (root: File, entities: Stream)
|
||||
|
||||
- WrittenContentLibrary
|
||||
- BookLibrary (root: BookLibrary)
|
||||
- Entities: Book, BookSeries
|
||||
- Value Objects: BookMetadata, SeriesInfo
|
||||
|
||||
- ComicLibrary (root: ComicLibrary)
|
||||
- Entities: ComicBook, ComicSeries, Manga, GraphicNovel
|
||||
- Value Objects: ComicMetadata, SeriesInfo
|
||||
|
||||
- PeriodicalLibrary (root: PeriodicalLibrary)
|
||||
- Entities: Magazine, MagazineIssue
|
||||
- Value Objects: PeriodicalMetadata, IssueInfo
|
||||
|
||||
- AcademicLibrary (root: AcademicLibrary)
|
||||
- Entities: AcademicPaper
|
||||
- Value Objects: AcademicMetadata, CitationInfo
|
||||
|
||||
- MiscWrittenContentLibrary (root: MiscWrittenContentLibrary)
|
||||
- Entities: SheetMusic, Screenplay
|
||||
- Value Objects: SheetMusicMetadata, ScreenplayMetadata
|
||||
|
||||
## Value Objects
|
||||
- BaseMetadata
|
||||
- VideoMetadata
|
||||
@@ -171,6 +192,36 @@
|
||||
- FileManagementService
|
||||
- LanguageTrackManager
|
||||
- CrossMediaRelationshipManager
|
||||
- ContentCurationService
|
||||
- UserActivityTrackingService
|
||||
- ContentSynchronizationService
|
||||
|
||||
## Domain Events
|
||||
|
||||
- MediaItemAdded
|
||||
- MediaItemRemoved
|
||||
- PlaylistCreated
|
||||
- PlaylistUpdated
|
||||
- UserPreferencesChanged
|
||||
- MetadataUpdated
|
||||
- FileTranscoded
|
||||
- StreamStarted
|
||||
- StreamEnded
|
||||
|
||||
## Bounded Contexts
|
||||
|
||||
- MediaManagement
|
||||
- Aggregates: VideoLibrary, AudioLibrary, PodcastLibrary, WrittenContentLibrary, PhotoLibrary
|
||||
- Services: MediaScanner, MetadataFetcher, TranscodingService
|
||||
- UserExperience
|
||||
- Aggregates: UserProfile
|
||||
- Services: RecommendationEngine, ContentCurationService, UserActivityTrackingService
|
||||
- ContentDelivery
|
||||
- Aggregates: FileManagement
|
||||
- Services: StreamingService, ContentSynchronizationService
|
||||
- MetadataManagement
|
||||
- Aggregates: SupplementaryContentLibrary
|
||||
- Services: LyricsMatchingService, ArtworkManagementService
|
||||
|
||||
## Repositories
|
||||
- VideoRepository
|
||||
|
||||
@@ -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,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>
|
||||
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.AudioLibrary.AudioLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the audio metadata of a media element.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Title}")]
|
||||
public class AudioMetadata : BaseMetadata
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the duration of the video in seconds.
|
||||
/// </summary>
|
||||
public int DurationInSeconds { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sample rate of the audio in Hz.
|
||||
/// </summary>
|
||||
public int SampleRate { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of audio channels.
|
||||
/// </summary>
|
||||
public int Channels { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the bit depth of the audio.
|
||||
/// </summary>
|
||||
public Optional<int> BitDepth { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the audio codec used.
|
||||
/// </summary>
|
||||
public Optional<string> AudioCodec { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the bitrate of the audio in kbps.
|
||||
/// </summary>
|
||||
public Optional<int> Bitrate { get; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AudioMetadata"/> class.
|
||||
/// </summary>
|
||||
/// <param name="title">The title of the audio.</param>
|
||||
/// <param name="originalTitle">The optional original title of the video.</param>
|
||||
/// <param name="durationInSeconds">The duration of the audio, in seconds.</param>
|
||||
/// <param name="sampleRate">The sample rate of the audio, in Hz.</param>
|
||||
/// <param name="channels">The number of audio channels.</param>
|
||||
/// <param name="release">The release information of the audio.</param>
|
||||
/// <param name="description">The description of the audio.</param>
|
||||
/// <param name="language">The language of the audio.</param>
|
||||
/// <param name="originalLanguage">The optional original language of the video.</param>
|
||||
/// <param name="bitDepth">The bit depth of the audio.</param>
|
||||
/// <param name="audioCodec">The audio codec used.</param>
|
||||
/// <param name="genres">The genres of the audio.</param>
|
||||
/// <param name="tags">The tags associated with the audio.</param>
|
||||
public AudioMetadata(
|
||||
string title,
|
||||
Optional<string> originalTitle,
|
||||
int durationInSeconds,
|
||||
int sampleRate,
|
||||
int channels,
|
||||
ReleaseInfo release,
|
||||
Optional<string> description,
|
||||
List<Genre> genres,
|
||||
List<Tag> tags,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> originalLanguage,
|
||||
Optional<int> bitDepth,
|
||||
Optional<string> audioCodec,
|
||||
Optional<int> bitrate)
|
||||
: base(title, originalTitle, release, description, genres, tags, language, originalLanguage)
|
||||
{
|
||||
DurationInSeconds = durationInSeconds;
|
||||
SampleRate = sampleRate;
|
||||
Channels = channels;
|
||||
BitDepth = bitDepth;
|
||||
AudioCodec = audioCodec;
|
||||
Bitrate = bitrate;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="AudioMetadata"/> class.
|
||||
/// </summary>
|
||||
/// <param name="title">The title of the audio.</param>
|
||||
/// <param name="originalTitle">The optional original title of the video.</param>
|
||||
/// <param name="durationInSeconds">The duration of the audio, in seconds.</param>
|
||||
/// <param name="sampleRate">The sample rate of the audio, in Hz.</param>
|
||||
/// <param name="channels">The number of audio channels.</param>
|
||||
/// <param name="release">The release information of the audio.</param>
|
||||
/// <param name="description">The description of the audio.</param>
|
||||
/// <param name="language">The language of the audio.</param>
|
||||
/// <param name="originalLanguage">The optional original language of the video.</param>
|
||||
/// <param name="bitDepth">The bit depth of the audio.</param>
|
||||
/// <param name="audioCodec">The audio codec used.</param>
|
||||
/// <param name="genres">The genres of the audio.</param>
|
||||
/// <param name="tags">The tags associated with the audio.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{T}"/> containing either a successfully created <see cref="AudioMetadata"/> or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<AudioMetadata> Create(
|
||||
string title,
|
||||
Optional<string> originalTitle,
|
||||
int durationInSeconds,
|
||||
int sampleRate,
|
||||
int channels,
|
||||
ReleaseInfo release,
|
||||
Optional<string>
|
||||
description,
|
||||
List<Genre> genres,
|
||||
List<Tag> tags,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> originalLanguage,
|
||||
Optional<int> bitDepth,
|
||||
Optional<string> audioCodec,
|
||||
Optional<int> bitrate)
|
||||
{
|
||||
return new AudioMetadata(
|
||||
title,
|
||||
originalTitle,
|
||||
durationInSeconds,
|
||||
sampleRate,
|
||||
channels,
|
||||
release,
|
||||
description,
|
||||
genres,
|
||||
tags,
|
||||
language,
|
||||
originalLanguage,
|
||||
bitDepth,
|
||||
audioCodec,
|
||||
bitrate);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
foreach (var component in base.GetEqualityComponents())
|
||||
yield return component;
|
||||
yield return DurationInSeconds;
|
||||
yield return SampleRate;
|
||||
yield return Channels;
|
||||
yield return BitDepth;
|
||||
yield return AudioCodec;
|
||||
yield return Bitrate;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+3
-3
@@ -5,7 +5,7 @@ using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.FileManagementAggregate.ValueObjects;
|
||||
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the information of a file.
|
||||
@@ -41,7 +41,7 @@ public class FileInfo : ValueObject
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// Initializes a new instance of the <see cref="FileInfo"/> class.
|
||||
/// </summary>
|
||||
/// <param name="path">The full path of the file.</param>
|
||||
/// <param name="fileExtension">The file extension.</param>
|
||||
@@ -60,7 +60,7 @@ public class FileInfo : ValueObject
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="FileInfo"/>.
|
||||
/// Creates a new instance of the <see cref="FileInfo"/> class.
|
||||
/// </summary>
|
||||
/// <param name="path">The full path of the file.</param>
|
||||
/// <param name="fileExtension">The file extension.</param>
|
||||
+21
-7
@@ -5,7 +5,7 @@ using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.FileManagementAggregate.ValueObjects;
|
||||
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the information about a media stream.
|
||||
@@ -56,7 +56,7 @@ public class StreamInfo : ValueObject
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// Initializes a new instance of the <see cref="StreamInfo"/> class.
|
||||
/// </summary>
|
||||
/// <param name="streamId">The unique identifier for the stream.</param>
|
||||
/// <param name="mimeType">The MIME type of the stream content.</param>
|
||||
@@ -66,8 +66,15 @@ public class StreamInfo : ValueObject
|
||||
/// <param name="frameRate">The frame rate of the stream (for video).</param>
|
||||
/// <param name="sampleRate">The sample rate of the stream (for audio).</param>
|
||||
/// <param name="channels">The number of channels (for audio).</param>
|
||||
private StreamInfo(string streamId, string mimeType, int bitrate, string codec,
|
||||
Optional<string> resolution = default, Optional<float> frameRate = default, Optional<int> sampleRate = default, Optional<int> channels = default)
|
||||
private StreamInfo(
|
||||
string streamId,
|
||||
string mimeType,
|
||||
int bitrate,
|
||||
string codec,
|
||||
Optional<string> resolution,
|
||||
Optional<float> frameRate,
|
||||
Optional<int> sampleRate,
|
||||
Optional<int> channels)
|
||||
{
|
||||
StreamId = streamId;
|
||||
MimeType = mimeType;
|
||||
@@ -82,7 +89,7 @@ public class StreamInfo : ValueObject
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="StreamInfo"/>.
|
||||
/// Creates a new instance of the <see cref="StreamInfo"/> class.
|
||||
/// </summary>
|
||||
/// <param name="streamId">The unique identifier for the stream.</param>
|
||||
/// <param name="mimeType">The MIME type of the stream content.</param>
|
||||
@@ -95,8 +102,15 @@ public class StreamInfo : ValueObject
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{T}"/> containing either a successfully created <see cref="StreamInfo"/> or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<StreamInfo> Create(string streamId, string mimeType, int bitrate, string codec,
|
||||
Optional<string> resolution = default, Optional<float> frameRate = default, Optional<int> sampleRate = default, Optional<int> channels = default)
|
||||
public static ErrorOr<StreamInfo> Create(
|
||||
string streamId,
|
||||
string mimeType,
|
||||
int bitrate,
|
||||
string codec,
|
||||
Optional<string> resolution,
|
||||
Optional<float> frameRate,
|
||||
Optional<int> sampleRate,
|
||||
Optional<int> channels)
|
||||
{
|
||||
if (streamId is null)
|
||||
return Errors.FileManagement.StreamIdCannotBeEmpty;
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Enums;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
|
||||
#endregion
|
||||
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Aggregate Root for a media contributor.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Id}: {Name}")]
|
||||
public class MediaContributor : AggregateRoot<MediaContributorId, Guid>
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the name of the contributor.
|
||||
/// </summary>
|
||||
public MediaContributorName Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role of the contributor.
|
||||
/// </summary>
|
||||
public MediaContributorRole Role { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the biography of the contributor.
|
||||
/// </summary>
|
||||
public Optional<string> Biography { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date of birth of the contributor.
|
||||
/// </summary>
|
||||
public Optional<DateOnly> DateOfBirth { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date of death of the contributor.
|
||||
/// </summary>
|
||||
public Optional<DateOnly> DateOfDeath { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaContributor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier of the contributor.</param>
|
||||
/// <param name="name">The name of the contributor.</param>
|
||||
/// <param name="role">The role of the contributor.</param>
|
||||
/// <param name="dateOfBirth">The optional date of birth of the contributor.</param>
|
||||
/// <param name="dateOfBirth">The optional date of death of the contributor.</param>
|
||||
private MediaContributor(
|
||||
MediaContributorId id,
|
||||
MediaContributorName name,
|
||||
MediaContributorRole role,
|
||||
Optional<DateOnly> dateOfBirth,
|
||||
Optional<DateOnly> dateOfDeath)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
Role = role;
|
||||
DateOfBirth = dateOfBirth;
|
||||
DateOfDeath = dateOfDeath;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaContributor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier of the contributor.</param>
|
||||
/// <param name="name">The name of the contributor.</param>
|
||||
/// <returns>The created <see cref="MediaContributor"/> instance.</returns>
|
||||
public static ErrorOr<MediaContributor> Create(MediaContributorName name)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
throw new NotImplementedException();
|
||||
//return new MediaContributor(id, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaContributor"/> class, from a pre-existing <paramref name="id"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier of the contributor.</param>
|
||||
/// <param name="name">The name of the contributor.</param>
|
||||
/// <returns>The created <see cref="MediaContributor"/> instance.</returns>
|
||||
public static ErrorOr<MediaContributor> Create(
|
||||
MediaContributorId id,
|
||||
MediaContributorName name,
|
||||
MediaContributorRole role,
|
||||
Optional<DateOnly> dateOfBirth,
|
||||
Optional<DateOnly> dateOfDeath)
|
||||
{
|
||||
return new MediaContributor(id, name, role, dateOfBirth, dateOfDeath);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the name of a person.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DisplayName}")]
|
||||
public sealed class MediaContributorName : ValueObject
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the name by which the contributor is popularly known.
|
||||
/// </summary>
|
||||
public string DisplayName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the legal name of the contributor.
|
||||
/// </summary>
|
||||
public Optional<string> LegalName { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaContributorName"/> class.
|
||||
/// </summary>
|
||||
/// <param name="displayName">The name by which the contributor is popularly known.</param>
|
||||
/// <param name="legalName">The legal name of the contributor.</param>
|
||||
private MediaContributorName(string displayName, Optional<string> legalName)
|
||||
{
|
||||
DisplayName = displayName;
|
||||
LegalName = legalName;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaContributorName"/> class.
|
||||
/// </summary>
|
||||
/// <param name="displayName">The name by which the contributor is popularly known.</param>
|
||||
/// <param name="legalName">The legal name of the contributor.</param>
|
||||
/// <returns>The created <see cref="MediaContributorName"/> instance.</returns>
|
||||
public static ErrorOr<MediaContributorName> Create(string displayName, Optional<string> legalName)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new MediaContributorName(displayName, legalName);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return DisplayName;
|
||||
yield return LegalName;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the Id of a media contributor.
|
||||
/// </summary>
|
||||
public sealed class MediaContributorId : AggregateRootId<Guid>
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public override Guid Value { get; protected set; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaContributorId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
private MediaContributorId(Guid value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaContributorId"/> class.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="MediaContributorId"/> instance.</returns>
|
||||
public static MediaContributorId CreateUnique()
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new MediaContributorId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaContributorId"/> class, from a pre-existing <paramref name="value"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value used to create the <see cref="MediaContributorId"/> instance.</param>
|
||||
/// <returns>The created <see cref="MediaContributorId"/> instance.</returns>
|
||||
public static MediaContributorId Create(Guid value)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new MediaContributorId(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.ValueObjects;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Entity for a movie.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Id}: {Title}")]
|
||||
public sealed class Movie : Entity<MovieId>
|
||||
{
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
private readonly List<MediaContributorId> _contributors;
|
||||
private readonly List<Rating> _ratings;
|
||||
#endregion
|
||||
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the video metadata of the movie.
|
||||
/// </summary>
|
||||
public VideoMetadata Metadata { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of ratings for this movie.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<Rating> Ratings
|
||||
{
|
||||
get { return _ratings.AsReadOnly(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of media contributors (actors, directors, etc) starring in this movie.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<MediaContributorId> Contributors
|
||||
{
|
||||
get { return _contributors.AsReadOnly(); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Movie"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier of the movie.</param>
|
||||
/// <param name="metadata">The metadata of the movie.</param>
|
||||
/// <param name="contributors">The list of the contributors of the movie.</param>
|
||||
/// <param name="ratings">The list of ratings for the movie.</param>
|
||||
public Movie(MovieId id, VideoMetadata metadata, List<MediaContributorId> contributors, List<Rating> ratings) : base(id)
|
||||
{
|
||||
Id = id;
|
||||
Metadata = metadata;
|
||||
_contributors = contributors;
|
||||
_ratings = ratings;
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Movie"/> class.
|
||||
/// </summary>
|
||||
private Movie() // only needed during reflection
|
||||
{
|
||||
|
||||
}
|
||||
#pragma warning restore CS8618
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="Movie"/> class.
|
||||
/// </summary>
|
||||
/// <param name="metadata">The metadata of the movie.</param>
|
||||
/// <param name="contributors">The list of media contributors of the movie.</param>
|
||||
/// <param name="ratings">The list of ratings for the movie.</param>
|
||||
/// <returns>The created <see cref="Movie"/>.</returns>
|
||||
public static ErrorOr<Movie> Create(VideoMetadata metadata, List<MediaContributorId> contributors, List<Rating> ratings)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new Movie(MovieId.CreateUnique(), metadata, contributors, ratings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="Movie"/> class, with a pre-existing <paramref name="id"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">The object representing the id of the movie.</param>
|
||||
/// <param name="metadata">The metadata of the movie.</param>
|
||||
/// <param name="contributors">The list of media contributors of the movie.</param>
|
||||
/// <param name="ratings">The list of ratings for the movie.</param>
|
||||
/// <returns>The created <see cref="Movie"/>.</returns>
|
||||
public static ErrorOr<Movie> Create(MovieId id, VideoMetadata metadata, List<MediaContributorId> contributors, List<Rating> ratings)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new Movie(id, metadata, contributors, ratings);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service for managing movie libraries.
|
||||
/// </summary>
|
||||
public interface IMovieLibraryService
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the collection of movies in the library.
|
||||
/// </summary>
|
||||
public ICollection<Movie> Movies { get; }
|
||||
#endregion
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.Services;
|
||||
|
||||
public sealed class MovieLibraryService : IMovieLibraryService
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the collection of movies in the library.
|
||||
/// </summary>
|
||||
public ICollection<Movie> Movies
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the Id of a movie.
|
||||
/// </summary>
|
||||
public sealed class MovieId : ValueObject
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public Guid Value { get; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MovieId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
private MovieId(Guid value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MovieId"/> class.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="MovieId"/> instance.</returns>
|
||||
public static MovieId CreateUnique()
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new MovieId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MovieId"/> class, from a pre-existing <paramref name="value"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value used to create the <see cref="MovieId"/> instance.</param>
|
||||
/// <returns>The created <see cref="MovieId"/> instance.</returns>
|
||||
public static MovieId Create(Guid value)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new MovieId(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+37
-24
@@ -1,16 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Media;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the rating of a media element.
|
||||
/// Value Object for the video metadata of a media element.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Value}/{MaxValue}")]
|
||||
[DebuggerDisplay("{Title}")]
|
||||
public class VideoMetadata : BaseMetadata
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
@@ -22,7 +22,7 @@ public class VideoMetadata : BaseMetadata
|
||||
/// <summary>
|
||||
/// Gets the resolution of the video.
|
||||
/// </summary>
|
||||
public string Resolution { get; }
|
||||
public string Resolution { get; } // TODO: should be implemented as a value object with width, height, aspet ratio, etc.
|
||||
|
||||
/// <summary>
|
||||
/// Gets the frame rate of the video.
|
||||
@@ -38,20 +38,15 @@ public class VideoMetadata : BaseMetadata
|
||||
/// 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.
|
||||
/// Initializes a new instance of the <see cref="VideoMetadata"/> class.
|
||||
/// </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="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>
|
||||
@@ -62,10 +57,20 @@ public class VideoMetadata : BaseMetadata
|
||||
/// <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)
|
||||
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,
|
||||
List<Genre> genres,
|
||||
List<Tag> tags)
|
||||
: base(title, originalTitle, release, description, genres, tags, language, originalLanguage)
|
||||
{
|
||||
DurationInSeconds = durationInSeconds;
|
||||
@@ -73,13 +78,12 @@ public class VideoMetadata : BaseMetadata
|
||||
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"/>.
|
||||
/// Creates a new instance of the <see cref="VideoMetadata"/> class.
|
||||
/// </summary>
|
||||
/// <param name="title">The title of the video.</param>
|
||||
/// <param name="originalTitle">The optional original title of the video.</param>
|
||||
@@ -98,12 +102,23 @@ public class VideoMetadata : BaseMetadata
|
||||
/// <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)
|
||||
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,
|
||||
List<Genre> genres,
|
||||
List<Tag> tags)
|
||||
{
|
||||
return new VideoMetadata(title, originalTitle, durationInSeconds, resolution, release, description,
|
||||
language, originalLanguage, frameRate, videoCodec, audioCodec, genres, tags, contributors);
|
||||
language, originalLanguage, frameRate, videoCodec, audioCodec, genres, tags);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -116,8 +131,6 @@ public class VideoMetadata : BaseMetadata
|
||||
yield return FrameRate;
|
||||
yield return VideoCodec;
|
||||
yield return AudioCodec;
|
||||
foreach (var contributor in Contributors)
|
||||
yield return contributor;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Services;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service for managing video content.
|
||||
/// </summary>
|
||||
public interface IVideoLibraryService
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the service for managing a movie library.
|
||||
/// </summary>
|
||||
public IMovieLibraryService MovieLibraryService { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the service for managing a TV shows library.
|
||||
/// </summary>
|
||||
public ITvShowLibraryService TvShowLibraryService { get; }
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Services;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service for managing video content.
|
||||
/// </summary>
|
||||
public class VideoLibraryService : IVideoLibraryService
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the service for managing a movie library.
|
||||
/// </summary>
|
||||
public IMovieLibraryService MovieLibraryService { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the service for managing a TV shows library.
|
||||
/// </summary>
|
||||
public ITvShowLibraryService TvShowLibraryService { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VideoLibraryService"/> class.
|
||||
/// </summary>
|
||||
/// <param name="movieLibraryService">Injected movie library service.</param>
|
||||
/// <param name="tvShowLibraryService">Injected TV show library service.</param>
|
||||
public VideoLibraryService(IMovieLibraryService movieLibraryService, ITvShowLibraryService tvShowLibraryService)
|
||||
{
|
||||
MovieLibraryService = movieLibraryService;
|
||||
TvShowLibraryService = tvShowLibraryService;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
#endregion
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Entity for an episode.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Id}: {Title}")]
|
||||
public sealed class Episode : Entity<EpisodeId>
|
||||
{
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Entity for a season.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Id}: {Title}")]
|
||||
public sealed class Season : Entity<SeasonId>
|
||||
{
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for the service for managing TV show libraries.
|
||||
/// </summary>
|
||||
public interface ITvShowLibraryService
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the collection of TV shows in the library.
|
||||
/// </summary>
|
||||
public ICollection<TvShow> TvShows { get; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service for managing TV show libraries.
|
||||
/// </summary>
|
||||
public class TvShowLibraryService : ITvShowLibraryService
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the collection of TV shows in the library.
|
||||
/// </summary>
|
||||
public ICollection<TvShow> TvShows
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Entity for a TV show.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Id}: {Title}")]
|
||||
public sealed class TvShow : Entity<TvShowId>
|
||||
{
|
||||
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the Id of an episode.
|
||||
/// </summary>
|
||||
public sealed class EpisodeId : ValueObject
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public Guid Value { get; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EpisodeId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
private EpisodeId(Guid value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="EpisodeId"/> class.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="EpisodeId"/> instance.</returns>
|
||||
public static EpisodeId CreateUnique()
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new EpisodeId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="EpisodeId"/> class, from a pre-existing <paramref name="value"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value used to create the <see cref="EpisodeId"/> instance.</param>
|
||||
/// <returns>The created <see cref="EpisodeId"/> instance.</returns>
|
||||
public static EpisodeId Create(Guid value)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new EpisodeId(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+14
-14
@@ -2,12 +2,12 @@
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.ValueObjects.Media;
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the Id of a person.
|
||||
/// Value Object for the Id of a season.
|
||||
/// </summary>
|
||||
public sealed class PersonId : ValueObject
|
||||
public sealed class SeasonId : ValueObject
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public Guid Value { get; }
|
||||
@@ -15,10 +15,10 @@ public sealed class PersonId : ValueObject
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// Initializes a new instance of the <see cref="SeasonId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
private PersonId(Guid value)
|
||||
private SeasonId(Guid value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
@@ -26,24 +26,24 @@ public sealed class PersonId : ValueObject
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="PersonId"/>.
|
||||
/// Creates a new instance of the <see cref="SeasonId"/> class.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="PersonId"/> instance.</returns>
|
||||
public static PersonId CreateUnique()
|
||||
/// <returns>The created <see cref="SeasonId"/> instance.</returns>
|
||||
public static SeasonId CreateUnique()
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new PersonId(Guid.NewGuid());
|
||||
return new SeasonId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="PersonId"/> from <paramref name="value"/>.
|
||||
/// Creates a new instance of the <see cref="SeasonId"/> class, from a pre-existing <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)
|
||||
/// <param name="value">The value used to create the <see cref="SeasonId"/> instance.</param>
|
||||
/// <returns>The created <see cref="SeasonId"/> instance.</returns>
|
||||
public static SeasonId Create(Guid value)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new PersonId(value);
|
||||
return new SeasonId(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the Id of a TV show.
|
||||
/// </summary>
|
||||
public sealed class TvShowId : ValueObject
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public Guid Value { get; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TvShowId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
private TvShowId(Guid value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="TvShowId"/> class.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="TvShowId"/> instance.</returns>
|
||||
public static TvShowId CreateUnique()
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new TvShowId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="TvShowId"/> class, from a pre-existing <paramref name="value"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value used to create the <see cref="TvShowId"/> instance.</param>
|
||||
/// <returns>The created <see cref="TvShowId"/> instance.</returns>
|
||||
public static TvShowId Create(Guid value)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new TvShowId(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,336 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Enums;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Entity for a book.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Id}: {Title}")]
|
||||
public sealed class Book : Entity<BookId>
|
||||
{
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
private readonly List<MediaContributorId> _contributors;
|
||||
private readonly List<Rating> _ratings;
|
||||
private readonly List<Isbn> _isbns;
|
||||
#endregion
|
||||
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the written content metadata of the book.
|
||||
/// </summary>
|
||||
public WrittenContentMetadata Metadata { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the format of the book (e.g., Hardcover, Paperback).
|
||||
/// </summary>
|
||||
public BookFormat Format { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the edition of the book, if applicable.
|
||||
/// </summary>
|
||||
public Optional<string> Edition { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the volume or book number in the series, if applicable.
|
||||
/// </summary>
|
||||
public Optional<int> VolumeNumber { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the series name, if the book is part of a series.
|
||||
/// </summary>
|
||||
public Optional<string> Series { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ASIN (Amazon Standard Identification Number) of the book.
|
||||
/// </summary>
|
||||
public Optional<string> ASIN { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Goodreads ID of the book.
|
||||
/// </summary>
|
||||
public Optional<string> GoodreadsId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Library of Congress Control Number (LCCN) of the book.
|
||||
/// </summary>
|
||||
public Optional<string> LCCN { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OCLC Number (WorldCat identifier) of the book.
|
||||
/// </summary>
|
||||
public Optional<string> OCLCNumber { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Open Library ID of the book.
|
||||
/// </summary>
|
||||
public Optional<string> OpenLibraryId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the LibraryThing ID of the book.
|
||||
/// </summary>
|
||||
public Optional<string> LibraryThingId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Google Books ID of the book.
|
||||
/// </summary>
|
||||
public Optional<string> GoogleBooksId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Barnes & Noble ID of the book.
|
||||
/// </summary>
|
||||
public Optional<string> BarnesAndNobleId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Kobo ID of the book.
|
||||
/// </summary>
|
||||
public Optional<string> KoboId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Apple Books ID of the book.
|
||||
/// </summary>
|
||||
public Optional<string> AppleBooksId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of ISBN (International Standard Book Number) of the book.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<Isbn> ISBNs
|
||||
{
|
||||
get { return _isbns.AsReadOnly(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of media contributors (actors, directors, etc) starring in this book.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<MediaContributorId> Contributors
|
||||
{
|
||||
get { return _contributors.AsReadOnly(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of ratings for this book.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<Rating> Ratings
|
||||
{
|
||||
get { return _ratings.AsReadOnly(); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Book"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier of the book.</param>
|
||||
/// <param name="metadata">The metadata of the book.</param>
|
||||
/// <param name="format">The format of the book (e.g., Hardcover, Paperback).</param>
|
||||
/// <param name="edition">The optional edition of the book.</param>
|
||||
/// <param name="volumeNumber">The optional volume or book number in the series.</param>
|
||||
/// <param name="series">The optional series name, if the book is part of a series.</param>
|
||||
/// <param name="asin">The optional ASIN of the book.</param>
|
||||
/// <param name="goodreadsId">The optional Goodreads ID of the book.</param>
|
||||
/// <param name="lccn">The optional LCCN of the book.</param>
|
||||
/// <param name="oclcNumber">The optional OCLC Number of the book.</param>
|
||||
/// <param name="openLibraryId">The optional Open Library ID of the book.</param>
|
||||
/// <param name="libraryThingId">The optional LibraryThing ID of the book.</param>
|
||||
/// <param name="googleBooksId">The optional Google Books ID of the book.</param>
|
||||
/// <param name="barnesAndNobleId">The optional Barnes & Noble ID of the book.</param>
|
||||
/// <param name="koboId">The optional Kobo ID of the book.</param>
|
||||
/// <param name="appleBooksId">The optional Apple Books ID of the book.</param>
|
||||
/// <param name="isbns">The list of ISBNs of the book.</param>
|
||||
/// <param name="contributors">The list of media contributors of the book.</param>
|
||||
/// <param name="ratings">The list of ratings for the book.</param>
|
||||
public Book(
|
||||
BookId id,
|
||||
WrittenContentMetadata metadata,
|
||||
BookFormat format,
|
||||
Optional<string> edition,
|
||||
Optional<int> volumeNumber,
|
||||
Optional<string> series,
|
||||
Optional<string> asin,
|
||||
Optional<string> goodreadsId,
|
||||
Optional<string> lccn,
|
||||
Optional<string> oclcNumber,
|
||||
Optional<string> openLibraryId,
|
||||
Optional<string> libraryThingId,
|
||||
Optional<string> googleBooksId,
|
||||
Optional<string> barnesAndNobleId,
|
||||
Optional<string> koboId,
|
||||
Optional<string> appleBooksId,
|
||||
List<Isbn> isbns,
|
||||
List<MediaContributorId> contributors,
|
||||
List<Rating> ratings) : base(id)
|
||||
{
|
||||
Id = id;
|
||||
Metadata = metadata;
|
||||
Format = format;
|
||||
Edition = edition;
|
||||
VolumeNumber = volumeNumber;
|
||||
Series = series;
|
||||
ASIN = asin;
|
||||
GoodreadsId = goodreadsId;
|
||||
LCCN = lccn;
|
||||
OCLCNumber = oclcNumber;
|
||||
OpenLibraryId = openLibraryId;
|
||||
LibraryThingId = libraryThingId;
|
||||
GoogleBooksId = googleBooksId;
|
||||
BarnesAndNobleId = barnesAndNobleId;
|
||||
KoboId = koboId;
|
||||
AppleBooksId = appleBooksId;
|
||||
_isbns = isbns;
|
||||
_contributors = contributors;
|
||||
_ratings = ratings;
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Book"/> class.
|
||||
/// </summary>
|
||||
private Book() // only needed during reflection
|
||||
{
|
||||
|
||||
}
|
||||
#pragma warning restore CS8618
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="Book"/> class.
|
||||
/// </summary>
|
||||
/// <param name="metadata">The metadata of the book.</param>
|
||||
/// <param name="format">The format of the book (e.g., Hardcover, Paperback).</param>
|
||||
/// <param name="edition">The optional edition of the book.</param>
|
||||
/// <param name="volumeNumber">The optional volume or book number in the series.</param>
|
||||
/// <param name="series">The optional series name, if the book is part of a series.</param>
|
||||
/// <param name="asin">The optional ASIN of the book.</param>
|
||||
/// <param name="goodreadsId">The optional Goodreads ID of the book.</param>
|
||||
/// <param name="lccn">The optional LCCN of the book.</param>
|
||||
/// <param name="oclcNumber">The optional OCLC Number of the book.</param>
|
||||
/// <param name="openLibraryId">The optional Open Library ID of the book.</param>
|
||||
/// <param name="libraryThingId">The optional LibraryThing ID of the book.</param>
|
||||
/// <param name="googleBooksId">The optional Google Books ID of the book.</param>
|
||||
/// <param name="barnesAndNobleId">The optional Barnes & Noble ID of the book.</param>
|
||||
/// <param name="koboId">The optional Kobo ID of the book.</param>
|
||||
/// <param name="appleBooksId">The optional Apple Books ID of the book.</param>
|
||||
/// <param name="isbns">The list of ISBNs of the book.</param>
|
||||
/// <param name="contributors">The list of media contributors of the book.</param>
|
||||
/// <param name="ratings">The list of ratings for the book.</param>
|
||||
/// <returns>The created <see cref="Book"/>.</returns>
|
||||
public static ErrorOr<Book> Create(
|
||||
WrittenContentMetadata metadata,
|
||||
BookFormat format,
|
||||
Optional<string> edition,
|
||||
Optional<int> volumeNumber,
|
||||
Optional<string> series,
|
||||
Optional<string> asin,
|
||||
Optional<string> goodreadsId,
|
||||
Optional<string> lccn,
|
||||
Optional<string> oclcNumber,
|
||||
Optional<string> openLibraryId,
|
||||
Optional<string> libraryThingId,
|
||||
Optional<string> googleBooksId,
|
||||
Optional<string> barnesAndNobleId,
|
||||
Optional<string> koboId,
|
||||
Optional<string> appleBooksId,
|
||||
List<Isbn> isbns,
|
||||
List<MediaContributorId> contributors,
|
||||
List<Rating> ratings)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new Book(
|
||||
BookId.CreateUnique(),
|
||||
metadata,
|
||||
format,
|
||||
edition,
|
||||
volumeNumber,
|
||||
series,
|
||||
asin,
|
||||
goodreadsId,
|
||||
lccn,
|
||||
oclcNumber,
|
||||
openLibraryId,
|
||||
libraryThingId,
|
||||
googleBooksId,
|
||||
barnesAndNobleId,
|
||||
koboId,
|
||||
appleBooksId,
|
||||
isbns,
|
||||
contributors,
|
||||
ratings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="Book"/>, with a pre-existing <paramref name="id"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">The object representing the id of the book.</param>
|
||||
/// <param name="metadata">The metadata of the book.</param>
|
||||
/// <param name="format">The format of the book (e.g., Hardcover, Paperback).</param>
|
||||
/// <param name="edition">The optional edition of the book.</param>
|
||||
/// <param name="volumeNumber">The optional volume or book number in the series.</param>
|
||||
/// <param name="series">The optional series name, if the book is part of a series.</param>
|
||||
/// <param name="asin">The optional ASIN of the book.</param>
|
||||
/// <param name="goodreadsId">The optional Goodreads ID of the book.</param>
|
||||
/// <param name="lccn">The optional LCCN of the book.</param>
|
||||
/// <param name="oclcNumber">The optional OCLC Number of the book.</param>
|
||||
/// <param name="openLibraryId">The optional Open Library ID of the book.</param>
|
||||
/// <param name="libraryThingId">The optional LibraryThing ID of the book.</param>
|
||||
/// <param name="googleBooksId">The optional Google Books ID of the book.</param>
|
||||
/// <param name="barnesAndNobleId">The optional Barnes & Noble ID of the book.</param>
|
||||
/// <param name="koboId">The optional Kobo ID of the book.</param>
|
||||
/// <param name="appleBooksId">The optional Apple Books ID of the book.</param>
|
||||
/// <param name="isbns">The list of ISBNs of the book.</param>
|
||||
/// <param name="contributors">The list of media contributors of the book.</param>
|
||||
/// <param name="ratings">The list of ratings for the book.</param>
|
||||
/// <returns>The created <see cref="Book"/>.</returns>
|
||||
public static ErrorOr<Book> Create(
|
||||
BookId id,
|
||||
WrittenContentMetadata metadata,
|
||||
BookFormat format,
|
||||
Optional<string> edition,
|
||||
Optional<int> volumeNumber,
|
||||
Optional<string> series,
|
||||
Optional<string> asin,
|
||||
Optional<string> goodreadsId,
|
||||
Optional<string> lccn,
|
||||
Optional<string> oclcNumber,
|
||||
Optional<string> openLibraryId,
|
||||
Optional<string> libraryThingId,
|
||||
Optional<string> googleBooksId,
|
||||
Optional<string> barnesAndNobleId,
|
||||
Optional<string> koboId,
|
||||
Optional<string> appleBooksId,
|
||||
List<Isbn> isbns,
|
||||
List<MediaContributorId> contributors,
|
||||
List<Rating> ratings)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new Book(
|
||||
id,
|
||||
metadata,
|
||||
format,
|
||||
edition,
|
||||
volumeNumber,
|
||||
series,
|
||||
asin,
|
||||
goodreadsId,
|
||||
lccn,
|
||||
oclcNumber,
|
||||
openLibraryId,
|
||||
libraryThingId,
|
||||
googleBooksId,
|
||||
barnesAndNobleId,
|
||||
koboId,
|
||||
appleBooksId,
|
||||
isbns,
|
||||
contributors,
|
||||
ratings);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service for managing book libraries.
|
||||
/// </summary>
|
||||
public sealed class BookLibraryService : IBookLibraryService
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the collection of books in the library.
|
||||
/// </summary>
|
||||
public ICollection<Book> Books
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service for managing book libraries.
|
||||
/// </summary>
|
||||
public interface IBookLibraryService
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the collection of books in the library.
|
||||
/// </summary>
|
||||
ICollection<Book> Books { get; }
|
||||
|
||||
// ICollection<BookSeries> Series { get; }
|
||||
#endregion
|
||||
|
||||
// void AddBook(Book book);
|
||||
// void RemoveBook(Guid bookId);
|
||||
// void AddSeries(BookSeries series);
|
||||
// void RemoveSeries(Guid seriesId);
|
||||
// Book GetBook(Guid bookId);
|
||||
// BookSeries GetSeries(Guid seriesId);
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the Id of a book.
|
||||
/// </summary>
|
||||
public sealed class BookId : ValueObject
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public Guid Value { get; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BookId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
private BookId(Guid value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="BookId"/> class.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="BookId"/> instance.</returns>
|
||||
public static BookId CreateUnique()
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new BookId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="BookId"/> class, from a pre-existing <paramref name="value"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value used to create the <see cref="BookId"/> instance.</param>
|
||||
/// <returns>The created <see cref="BookId"/> instance.</returns>
|
||||
public static BookId Create(Guid value)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new BookId(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the Id of a book library.
|
||||
/// </summary>
|
||||
public sealed class BookLibraryId : ValueObject
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public Guid Value { get; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BookLibraryId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
private BookLibraryId(Guid value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="BookLibraryId"/> class.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="BookLibraryId"/> instance.</returns>
|
||||
public static ErrorOr<BookLibraryId> CreateUnique()
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new BookLibraryId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="BookLibraryId"/> class, from a pre-existing <paramref name="value"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value used to create the <see cref="BookLibraryId"/> instance.</param>
|
||||
/// <returns>The created <see cref="BookLibraryId"/> instance.</returns>
|
||||
public static ErrorOr<BookLibraryId> Create(Guid value)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new BookLibraryId(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Text.RegularExpressions;
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Enums;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the ISBN of a book.
|
||||
/// </summary>
|
||||
public sealed class Isbn : ValueObject
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the value of the ISBN.
|
||||
/// </summary>
|
||||
public string Value { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the format of the ISBN.
|
||||
/// </summary>
|
||||
public IsbnFormat Format { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Isbn"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
/// <param name="format">The format of the ISBN representing this object.</param>
|
||||
private Isbn(string value, IsbnFormat format)
|
||||
{
|
||||
Value = value;
|
||||
Format = format;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="Isbn"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
/// <param name="format">The format of the ISBN representing this object.</param>
|
||||
/// <returns>The created <see cref="Isbn"/> instance.</returns>
|
||||
public static ErrorOr<Isbn> Create(string value, IsbnFormat format)
|
||||
{
|
||||
// enforce invariants
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return Errors.WrittenContent.IsbnCannotBeEmpty;
|
||||
// remove hyphens and spaces, for validation
|
||||
string cleanedValue = Regex.Replace(value, @"[-\s]", string.Empty);
|
||||
switch (format)
|
||||
{
|
||||
case IsbnFormat.Isbn10:
|
||||
if (!IsValidIsbn10(cleanedValue))
|
||||
return Errors.WrittenContent.InvalidIsbn10Format;
|
||||
break;
|
||||
case IsbnFormat.Isbn13:
|
||||
if (!IsValidIsbn13(cleanedValue))
|
||||
return Errors.WrittenContent.InvalidIsbn13Format;
|
||||
break;
|
||||
default:
|
||||
return Errors.WrittenContent.UnknownIsbnFormat;
|
||||
}
|
||||
return new Isbn(value, format);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates an ISBN-10 string.
|
||||
/// </summary>
|
||||
/// <param name="isbn">The ISBN-10 string to validate, without hyphens or spaces.</param>
|
||||
/// <returns><see langword="true"/> if the ISBN-10 is valid, <see langword="false"/> otherwise.</returns>
|
||||
public static bool IsValidIsbn10(string isbn)
|
||||
{
|
||||
// ISBN-10 must be exactly 10 characters long
|
||||
if (isbn.Length != 10)
|
||||
return false;
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
// each of the first 9 characters must be a digit
|
||||
if (!char.IsDigit(isbn[i]))
|
||||
return false;
|
||||
// calculate the sum: each digit is multiplied by its position (10 to 2) and added
|
||||
sum += (10 - i) * (isbn[i] - '0');
|
||||
}
|
||||
// check the last character, which can be a digit or 'X'
|
||||
char lastChar = isbn[9];
|
||||
if (lastChar == 'X' || lastChar == 'x')
|
||||
sum += 10;
|
||||
else if (char.IsDigit(lastChar))
|
||||
sum += lastChar - '0';
|
||||
else
|
||||
return false;
|
||||
// the ISBN-10 is valid if the sum is divisible by 11
|
||||
return sum % 11 == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates an ISBN-13 string.
|
||||
/// </summary>
|
||||
/// <param name="isbn">The ISBN-13 string to validate, without hyphens or spaces.</param>
|
||||
/// <returns><see langword="true"/> if the ISBN-13 is valid, <see langword="false"/> otherwise.</returns>
|
||||
public static bool IsValidIsbn13(string isbn)
|
||||
{
|
||||
// ISBN-13 must be exactly 13 characters long
|
||||
if (isbn.Length != 13)
|
||||
return false;
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
// each of the first 12 characters must be a digit
|
||||
if (!char.IsDigit(isbn[i]))
|
||||
return false;
|
||||
// calculate the sum: alternate digits are multiplied by 3
|
||||
sum += (i % 2 == 0) ? isbn[i] - '0' : 3 * (isbn[i] - '0');
|
||||
}
|
||||
// calculate the check digit
|
||||
int checkDigit = 10 - (sum % 10);
|
||||
if (checkDigit == 10)
|
||||
checkDigit = 0;
|
||||
// the ISBN-13 is valid if the calculated check digit matches the last digit
|
||||
return checkDigit == (isbn[12] - '0');
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Value;
|
||||
yield return Format;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the metadata of a written media element.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Title}")]
|
||||
public class WrittenContentMetadata : BaseMetadata
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the publisher of the written content.
|
||||
/// </summary>
|
||||
public Optional<string> Publisher { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of pages in the written content.
|
||||
/// </summary>
|
||||
public Optional<int> PageCount { get; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WrittenContentMetadata"/> class.
|
||||
/// </summary>
|
||||
/// <param name="title">The title of the written content.</param>
|
||||
/// <param name="originalTitle">The optional original title of the video.</param>
|
||||
/// <param name="release">The release information of the written content.</param>
|
||||
/// <param name="description">The description of the written content.</param>
|
||||
/// <param name="genres">The genres of the written content.</param>
|
||||
/// <param name="tags">The tags associated with the written content.</param>
|
||||
/// <param name="language">The language of the written content.</param>
|
||||
/// <param name="originalLanguage">The optional original language of the video.</param>
|
||||
/// <param name="publisher">The publisher of the written content.</param>
|
||||
/// <param name="pageCount">The number of pages in the written content.</param>
|
||||
public WrittenContentMetadata(
|
||||
string title,
|
||||
Optional<string> originalTitle,
|
||||
ReleaseInfo release,
|
||||
Optional<string> description,
|
||||
List<Genre> genres,
|
||||
List<Tag> tags,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> originalLanguage,
|
||||
Optional<string> publisher,
|
||||
Optional<int> pageCount)
|
||||
: base(title, originalTitle, release, description, genres, tags, language, originalLanguage)
|
||||
{
|
||||
Publisher = publisher;
|
||||
PageCount = pageCount;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
foreach (var component in base.GetEqualityComponents())
|
||||
yield return component;
|
||||
yield return Publisher;
|
||||
yield return PageCount;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Services;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service for managing written content.
|
||||
/// </summary>
|
||||
public interface IWrittenContentLibraryService
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the service for managing book libraries.
|
||||
/// </summary>
|
||||
public IBookLibraryService BookLibraryService { get; }
|
||||
#endregion
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Services;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service for managing written content.
|
||||
/// </summary>
|
||||
public class WrittenContentLibraryService : IWrittenContentLibraryService
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the service for managing book libraries.
|
||||
/// </summary>
|
||||
public IBookLibraryService BookLibraryService { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WrittenContentLibraryService"/> class.
|
||||
/// </summary>
|
||||
/// <param name="bookLibraryService">Injected book library service.</param>
|
||||
public WrittenContentLibraryService(IBookLibraryService bookLibraryService)
|
||||
{
|
||||
BookLibraryService = bookLibraryService;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.Aggregates.VideoLibrary.Services;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.Services;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service for managing a media library.
|
||||
/// </summary>
|
||||
public interface IMediaLibraryService
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the service for managing a audio library.
|
||||
/// </summary>
|
||||
//public IAudioLibraryService AudioLibraryService { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the service for managing a video library.
|
||||
/// </summary>
|
||||
public IVideoLibraryService VideoLibraryService { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the service for managing a written content library.
|
||||
/// </summary>
|
||||
public IWrittenContentLibraryService WrittenContentLibraryService { get; }
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.Aggregates.VideoLibrary.Services;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.Services;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service for managing media libraries.
|
||||
/// </summary>
|
||||
public class MediaLibraryService : IMediaLibraryService
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the service for managing a video library.
|
||||
/// </summary>
|
||||
public IVideoLibraryService VideoLibraryService { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the service for managing a written content library.
|
||||
/// </summary>
|
||||
public IWrittenContentLibraryService WrittenContentLibraryService { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaLibraryService"/> class.
|
||||
/// </summary>
|
||||
/// <param name="videoLibraryService">Injected video library service.</param>
|
||||
/// <param name="writtenContentLibraryService">Injected written content library service.</param>
|
||||
public MediaLibraryService(IVideoLibraryService videoLibraryService, IWrittenContentLibraryService writtenContentLibraryService)
|
||||
{
|
||||
VideoLibraryService = videoLibraryService;
|
||||
WrittenContentLibraryService = writtenContentLibraryService;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user