Updates to .NET 9.0

This commit is contained in:
BinaryAlley committed 2024-11-13 20:46:54 +02:00
commit acbdb0a5f8
853 files changed
+34993 -10123

No files matched your search

@@ -1,12 +1,11 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO.Abstractions;
using System.Runtime.InteropServices;
#endregion
namespace Lumina.Domain.Common.DependencyInjection;
@@ -14,6 +13,7 @@ namespace Lumina.Domain.Common.DependencyInjection;
/// <summary>
/// Contains all services of the Domain layer.
/// </summary>
[ExcludeFromCodeCoverage]
public static class DomainLayerServices
{
/// <summary>
@@ -0,0 +1,57 @@
namespace Lumina.Domain.Common.Enums.AudioLibrary;
/// <summary>
/// Enumeration for the types of audio content libraries.
/// </summary>
public enum AudioContentType
{
/// <summary>
/// A musical composition typically consisting of vocals and/or instruments.
/// </summary>
Music,
/// <summary>
/// A recording of a book or other written work being read aloud.
/// </summary>
AudioBook,
/// <summary>
/// An audio recording of a live musical or spoken word performance.
/// </summary>
LivePerformance,
/// <summary>
/// A recorded conversation where one person asks questions and another provides answers.
/// </summary>
Interview,
/// <summary>
/// A new performance or recording of a previously released song.
/// </summary>
Cover,
/// <summary>
/// An alternative version of a recorded song, typically with altered instrumentation or structure.
/// </summary>
Remix,
/// <summary>
/// An audio recording used to create a specific acoustic environment or impression.
/// </summary>
Soundeffect,
/// <summary>
/// A digital audio file made available on the internet for downloading to a computer or mobile device.
/// </summary>
Podcast,
/// <summary>
/// A regularly scheduled broadcast program consisting of music, talk, or other audio content.
/// </summary>
RadioShow,
/// <summary>
/// A collection of music used as background sound for a movie, TV show, video game, or other media.
/// </summary>
Soundtrack,
}
@@ -0,0 +1,27 @@
namespace Lumina.Domain.Common.Enums.AudioLibrary;
/// <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.BookLibrary;
/// <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.BookLibrary;
/// <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.BookLibrary;
/// <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
}
@@ -0,0 +1,62 @@
namespace Lumina.Domain.Common.Enums.BookLibrary;
/// <summary>
/// Enumeration for the types of written content libraries.
/// </summary>
public enum WrittenContentType
{
/// <summary>
/// A printed or written literary work.
/// </summary>
Book,
/// <summary>
/// An electronic version of a printed book.
/// </summary>
EBook,
/// <summary>
/// A set of related books published in succession.
/// </summary>
BookSeries,
/// <summary>
/// A magazine or book containing sequential art in the form of a narrative.
/// </summary>
ComicBook,
/// <summary>
/// A set of related comic books published in succession.
/// </summary>
ComicSeries,
/// <summary>
/// A periodical publication containing articles, stories, and other content.
/// </summary>
Magazine,
/// <summary>
/// A style of Japanese comic books and graphic novels.
/// </summary>
Manga,
/// <summary>
/// A novel in comic-strip format, typically with sophisticated artwork and complex storylines.
/// </summary>
GraphicNovel,
/// <summary>
/// A scholarly article presenting original research or analysis.
/// </summary>
AcademicPaper,
/// <summary>
/// A handwritten or printed form of musical notation.
/// </summary>
SheetMusic,
/// <summary>
/// A script for a film, television program, or other visual media.
/// </summary>
Screenplay,
}
@@ -0,0 +1,37 @@
namespace Lumina.Domain.Common.Enums.FileSystem;
/// <summary>
/// Enumeration for file access mode types.
/// </summary>
public enum FileAccessMode
{
/// <summary>
/// Represents the ability to list the contents of a directory.
/// </summary>
ListDirectory,
/// <summary>
/// Represents the ability to read file or directory properties.
/// </summary>
ReadProperties,
/// <summary>
/// Represents the ability to read the contents of a file.
/// </summary>
ReadContents,
/// <summary>
/// Represents the ability to write to a file or directory.
/// </summary>
Write,
/// <summary>
/// Represents the ability to execute a file.
/// </summary>
Execute,
/// <summary>
/// Represents the ability to delete a file or directory.
/// </summary>
Delete,
}
@@ -0,0 +1,22 @@
namespace Lumina.Domain.Common.Enums.FileSystem;
/// <summary>
/// Enumeration for file system item statuses types.
/// </summary>
public enum FileSystemItemStatus
{
/// <summary>
/// Indicates that the file system item is accessible.
/// </summary>
Accessible,
/// <summary>
/// Indicates that the file system item is inaccessible due to permissions or other restrictions.
/// </summary>
Inaccessible,
/// <summary>
/// Indicates that the status of the file system item could not be determined due to an unknown error.
/// </summary>
UnknownError
}
@@ -0,0 +1,22 @@
namespace Lumina.Domain.Common.Enums.FileSystem;
/// <summary>
/// Enumeration for the types of file system elements.
/// </summary>
public enum FileSystemItemType
{
/// <summary>
/// Represents a file system root, which can be a drive on Windows, and a path separator on Unix.
/// </summary>
Root,
/// <summary>
/// Represents a directory, which is a directory that can contain other directories or files.
/// </summary>
Directory,
/// <summary>
/// Represents a file, which is a document, executable, or other data stored on the file system.
/// </summary>
File
}
@@ -0,0 +1,17 @@
namespace Lumina.Domain.Common.Enums.FileSystem;
/// <summary>
/// Enumeration for platform types.
/// </summary>
public enum PlatformType
{
/// <summary>
/// Represents Unix-based operating systems, including Linux and macOS.
/// </summary>
Unix,
/// <summary>
/// Represents Microsoft Windows operating systems.
/// </summary>
Windows,
}
@@ -0,0 +1,187 @@
namespace Lumina.Domain.Common.Enums.MediaLibrary;
/// <summary>
/// Enumeration for the types of libraries.
/// </summary>
public enum LibraryType
{
/// <summary>
/// Traditional printed books in physical format.
/// </summary>
Book,
/// <summary>
/// Digital books in electronic format (e.g., PDF, EPUB, MOBI).
/// </summary>
EBook,
/// <summary>
/// Comic books in digital or physical format.
/// </summary>
ComicBook,
/// <summary>
/// Periodical publications containing articles and illustrations.
/// </summary>
Magazine,
/// <summary>
/// Periodical publication containing news.
/// </summary>
Newspaper,
/// <summary>
/// Japanese-style comics and graphic novels.
/// </summary>
Manga,
/// <summary>
/// Extended comic-format narratives, typically containing a complete story.
/// </summary>
GraphicNovel,
/// <summary>
/// Scholarly articles and research papers.
/// </summary>
AcademicPaper,
/// <summary>
/// Musical notation and scores.
/// </summary>
SheetMusic,
/// <summary>
/// Television series and episodic content.
/// </summary>
TvShow,
/// <summary>
/// Feature-length films and motion pictures.
/// </summary>
Movie,
/// <summary>
/// Non-fiction films presenting factual information.
/// </summary>
Documentary,
/// <summary>
/// Japanese animation series and films.
/// </summary>
Anime,
/// <summary>
/// Recorded live music performances and concerts.
/// </summary>
ConcertVideo,
/// <summary>
/// Educational and instructional videos.
/// </summary>
TutorialVideo,
/// <summary>
/// Personally recorded videos and family footage.
/// </summary>
HomeVideo,
/// <summary>
/// Videos sourced from YouTube platform.
/// </summary>
YouTubeVideo,
/// <summary>
/// Professional or amateur music video productions.
/// </summary>
MusicVideo,
/// <summary>
/// Videos recorded during live performances or events.
/// </summary>
LiveRecordingVideo,
/// <summary>
/// Recorded conversations and Q&A sessions in video format.
/// </summary>
InterviewVideo,
/// <summary>
/// Videos of musical performances covering other artists' work.
/// </summary>
CoverSongVideo,
/// <summary>
/// Video format podcasts and episodic content.
/// </summary>
PodcastVideo,
/// <summary>
/// Audio recordings of musical content.
/// </summary>
Music,
/// <summary>
/// Narrated books in audio format.
/// </summary>
Audiobook,
/// <summary>
/// Audio recordings from live performances or events.
/// </summary>
LiveRecordingAudio,
/// <summary>
/// Recorded conversations and Q&A sessions in audio format.
/// </summary>
InterviewAudio,
/// <summary>
/// Audio recordings of musical performances covering other artists' work.
/// </summary>
CoverSongAudio,
/// <summary>
/// Modified or reinterpreted versions of original musical recordings.
/// </summary>
Remix,
/// <summary>
/// Audio clips used for sound design and production.
/// </summary>
SoundEffect,
/// <summary>
/// Audio format podcasts and episodic content.
/// </summary>
PodcastAudio,
/// <summary>
/// Digital images and photographs.
/// </summary>
Photo,
/// <summary>
/// Curated sequences of media items.
/// </summary>
Playlist,
/// <summary>
/// Grouped sets of related media items.
/// </summary>
Collection,
/// <summary>
/// Text files containing dialogue translations for video content.
/// </summary>
Subtitles,
/// <summary>
/// Text files containing words and timing for musical content.
/// </summary>
Lyrics,
/// <summary>
/// A collection of media that does not fit into any other category.
/// </summary>
Other
}
@@ -0,0 +1,12 @@
namespace Lumina.Domain.Common.Enums.MediaLibrary;
/// <summary>
/// Enumeration for the types of miscellaneous content libraries.
/// </summary>
public enum MiscellaneousContentType
{
/// <summary>
/// A collection of media that does not fit into any other category.
/// </summary>
Other,
}
@@ -0,0 +1,87 @@
namespace Lumina.Domain.Common.Enums.PhotoLibrary;
/// <summary>
/// Enumeration for known image types.
/// </summary>
public enum ImageType
{
/// <summary>
/// No image type specified.
/// </summary>
None,
/// <summary>
/// Bitmap image format.
/// </summary>
BMP,
/// <summary>
/// Graphics Interchange Format (GIF).
/// </summary>
GIF,
/// <summary>
/// Portable Network Graphics (PNG) format.
/// </summary>
PNG,
/// <summary>
/// Tagged Image File Format (TIFF).
/// </summary>
TIFF,
/// <summary>
/// Joint Photographic Experts Group (JPEG) format.
/// </summary>
JPEG,
/// <summary>
/// Canon-specific JPEG format.
/// </summary>
JPEG_CANON,
/// <summary>
/// Unknown JPEG format.
/// </summary>
JPEG_UNKNOWN,
/// <summary>
/// Macintosh Picture (PICT) format.
/// </summary>
PICT,
/// <summary>
/// Icon (ICO) format.
/// </summary>
ICO,
/// <summary>
/// Photoshop Document (PSD) format.
/// </summary>
PSD,
/// <summary>
/// JPEG 2000 format.
/// </summary>
JPEG2000,
/// <summary>
/// AV1 Image File Format (AVIF).
/// </summary>
AVIF,
/// <summary>
/// Web Picture (WEBP) format.
/// </summary>
WEBP,
/// <summary>
/// Truevision TGA format.
/// </summary>
TGA,
/// <summary>
/// Scalable Vector Graphics (SVG) format.
/// </summary>
SVG
}
@@ -0,0 +1,12 @@
namespace Lumina.Domain.Common.Enums.PhotoLibrary;
/// <summary>
/// Enumeration for the types of visual content libraries.
/// </summary>
public enum VisualContentType
{
/// <summary>
/// A collection of photographs organized together.
/// </summary>
PhotoAlbum,
}
@@ -0,0 +1,62 @@
namespace Lumina.Domain.Common.Enums.VideoLibrary;
/// <summary>
/// Enumeration for the types of video content libraries.
/// </summary>
public enum VideoContentType
{
/// <summary>
/// A series of related episodes broadcast on television or streaming platforms.
/// </summary>
TvShow,
/// <summary>
/// A feature-length film produced for cinema or home viewing.
/// </summary>
Movie,
/// <summary>
/// A collection of related films released in succession.
/// </summary>
FilmSeries,
/// <summary>
/// A collection of related films, TV shows, and other media sharing a fictional universe.
/// </summary>
FilmFranchise,
/// <summary>
/// A live musical performance recorded on video.
/// </summary>
Concert,
/// <summary>
/// A non-fictional film or TV program presenting facts and information about a specific subject.
/// </summary>
Documentary,
/// <summary>
/// An instructional video designed to teach a skill or provide information on a specific topic.
/// </summary>
Tutorial,
/// <summary>
/// Privately recorded videos, often for personal use or sharing with friends and family.
/// </summary>
Personal,
/// <summary>
/// Japanese animated productions, typically characterized by colorful graphics and vibrant characters.
/// </summary>
Anime,
/// <summary>
/// Videos hosted on or originating from the YouTube platform.
/// </summary>
Youtube,
/// <summary>
/// A short video, typically set to music, such as a music video or promotional clip.
/// </summary>
Videoclip,
}
@@ -0,0 +1,32 @@
namespace Lumina.Domain.Common.Enums.VideoLibrary;
/// <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,
}
@@ -1,32 +0,0 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
#endregion
namespace Lumina.Domain.Common.Errors;
/// <summary>
/// File management error types.
/// </summary>
public static partial class Errors
{
public static class FileManagement
{
public static Error ParentNodeCannotBeNull => Error.Failure(nameof(ParentNodeCannotBeNull));
public static Error FileCopyError => Error.Failure(nameof(FileCopyError));
public static Error FileMoveError => Error.Failure(nameof(FileMoveError));
public static Error DirectoryCopyError => Error.Failure(nameof(DirectoryCopyError));
public static Error DirectoryMoveError => Error.Failure(nameof(DirectoryMoveError));
public static Error FileNotFound => Error.NotFound(nameof(FileNotFound));
public static Error InvalidPath => Error.Validation(nameof(InvalidPath));
public static Error PathCannotBeEmpty => Error.Validation(nameof(PathCannotBeEmpty));
public static Error ExtensionCannotBeEmpty => Error.Validation(nameof(ExtensionCannotBeEmpty));
public static Error StreamIdCannotBeEmpty => Error.Validation(nameof(StreamIdCannotBeEmpty));
public static Error CodecCannotBeEmpty => Error.Validation(nameof(CodecCannotBeEmpty));
public static Error BitrateMustBeAPositiveNumber => Error.Validation(nameof(BitrateMustBeAPositiveNumber));
public static Error CannotNavigateUp => Error.Failure(nameof(CannotNavigateUp));
public static Error NameCannotBeEmpty => Error.Validation(nameof(NameCannotBeEmpty));
public static Error FileAlreadyExists => Error.Conflict(nameof(FileAlreadyExists));
public static Error DirectoryNotFound => Error.NotFound(nameof(DirectoryNotFound));
public static Error DirectoryAlreadyExists => Error.Conflict(nameof(DirectoryAlreadyExists));
}
}
@@ -0,0 +1,33 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
#endregion
namespace Lumina.Domain.Common.Errors;
/// <summary>
/// File management error types.
/// </summary>
public static partial class Errors
{
public static class FileSystemManagement
{
public static Error ParentNodeCannotBeNull => Error.Failure(description: nameof(ParentNodeCannotBeNull));
public static Error PathMustBeMaximum260CharactersLong => Error.Failure(description: nameof(PathMustBeMaximum260CharactersLong));
public static Error FileCopyError => Error.Failure(description: nameof(FileCopyError));
public static Error FileMoveError => Error.Failure(description: nameof(FileMoveError));
public static Error DirectoryCopyError => Error.Failure(description: nameof(DirectoryCopyError));
public static Error DirectoryMoveError => Error.Failure(description: nameof(DirectoryMoveError));
public static Error FileNotFound => Error.NotFound(description: nameof(FileNotFound));
public static Error InvalidPath => Error.Validation(description: nameof(InvalidPath));
public static Error PathCannotBeEmpty => Error.Validation(description: nameof(PathCannotBeEmpty));
public static Error ExtensionCannotBeEmpty => Error.Validation(description: nameof(ExtensionCannotBeEmpty));
public static Error StreamIdCannotBeEmpty => Error.Validation(description: nameof(StreamIdCannotBeEmpty));
public static Error CodecCannotBeEmpty => Error.Validation(description: nameof(CodecCannotBeEmpty));
public static Error BitrateMustBeAPositiveNumber => Error.Validation(description: nameof(BitrateMustBeAPositiveNumber));
public static Error CannotNavigateUp => Error.Failure(description: nameof(CannotNavigateUp));
public static Error NameCannotBeEmpty => Error.Validation(description: nameof(NameCannotBeEmpty));
public static Error FileAlreadyExists => Error.Conflict(description: nameof(FileAlreadyExists));
public static Error DirectoryNotFound => Error.NotFound(description: nameof(DirectoryNotFound));
public static Error DirectoryAlreadyExists => Error.Conflict(description: nameof(DirectoryAlreadyExists));
}
}
@@ -0,0 +1,23 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
#endregion
namespace Lumina.Domain.Common.Errors;
/// <summary>
/// Media Library error types.
/// </summary>
public static partial class Errors
{
public static class Library
{
public static Error UserIdCannotBeEmpty => Error.Forbidden(description: nameof(UserIdCannotBeEmpty));
public static Error LibraryAlreadyExists => Error.Conflict(description: nameof(LibraryAlreadyExists));
public static Error LibraryTypeCannotBeNull => Error.Validation(description: nameof(LibraryTypeCannotBeNull));
public static Error UnknownLibraryType => Error.Unexpected(description: nameof(UnknownLibraryType));
public static Error PathsListCannotBeNull => Error.Validation(description: nameof(PathsListCannotBeNull));
public static Error PathsListCannotBeEmpty => Error.Validation(description: nameof(PathsListCannotBeEmpty));
public static Error TitleCannotBeEmpty => Error.Validation(description: nameof(TitleCannotBeEmpty));
public static Error TitleMustBeMaximum255CharactersLong => Error.Validation(description: nameof(TitleMustBeMaximum255CharactersLong));
}
}
@@ -11,15 +11,15 @@ public static partial class Errors
{
public static class MediaContributor
{
public static Error ContributorsListCannotBeNull => Error.Validation(nameof(ContributorsListCannotBeNull));
public static Error ContributorNameCannotBeEmpty => Error.Validation(nameof(ContributorNameCannotBeEmpty));
public static Error ContributorDisplayNameCannotBeEmpty => Error.Validation(nameof(ContributorDisplayNameCannotBeEmpty));
public static Error ContributorDisplayNameMustBeMaximum100CharactersLong => Error.Validation(nameof(ContributorDisplayNameMustBeMaximum100CharactersLong));
public static Error ContributorLegalNameMustBeMaximum100CharactersLong => Error.Validation(nameof(ContributorLegalNameMustBeMaximum100CharactersLong));
public static Error RoleNameCannotBeEmpty => Error.Validation(nameof(RoleNameCannotBeEmpty));
public static Error RoleNameMustBeMaximum50CharactersLong => Error.Validation(nameof(RoleNameMustBeMaximum50CharactersLong));
public static Error RoleCategoryCannotBeEmpty => Error.Validation(nameof(RoleCategoryCannotBeEmpty));
public static Error RoleCategoryMustBeMaximum50CharactersLong => Error.Validation(nameof(RoleCategoryMustBeMaximum50CharactersLong));
public static Error ContributorRoleCannotBeNull => Error.Validation(nameof(ContributorRoleCannotBeNull));
public static Error ContributorsListCannotBeNull => Error.Validation(description: nameof(ContributorsListCannotBeNull));
public static Error ContributorNameCannotBeEmpty => Error.Validation(description: nameof(ContributorNameCannotBeEmpty));
public static Error ContributorDisplayNameCannotBeEmpty => Error.Validation(description: nameof(ContributorDisplayNameCannotBeEmpty));
public static Error ContributorDisplayNameMustBeMaximum100CharactersLong => Error.Validation(description: nameof(ContributorDisplayNameMustBeMaximum100CharactersLong));
public static Error ContributorLegalNameMustBeMaximum100CharactersLong => Error.Validation(description: nameof(ContributorLegalNameMustBeMaximum100CharactersLong));
public static Error RoleNameCannotBeEmpty => Error.Validation(description: nameof(RoleNameCannotBeEmpty));
public static Error RoleNameMustBeMaximum50CharactersLong => Error.Validation(description: nameof(RoleNameMustBeMaximum50CharactersLong));
public static Error RoleCategoryCannotBeEmpty => Error.Validation(description: nameof(RoleCategoryCannotBeEmpty));
public static Error RoleCategoryMustBeMaximum50CharactersLong => Error.Validation(description: nameof(RoleCategoryMustBeMaximum50CharactersLong));
public static Error ContributorRoleCannotBeNull => Error.Validation(description: nameof(ContributorRoleCannotBeNull));
}
}
@@ -11,36 +11,36 @@ public static partial class Errors
{
public static class Metadata
{
public static Error MetadataCannotBeNull => Error.Validation(nameof(MetadataCannotBeNull));
public static Error TitleCannotBeEmpty => Error.Validation(nameof(TitleCannotBeEmpty));
public static Error TitleMustBeMaximum255CharactersLong => Error.Validation(nameof(TitleMustBeMaximum255CharactersLong));
public static Error OriginalTitleMustBeMaximum255CharactersLong => Error.Validation(nameof(OriginalTitleMustBeMaximum255CharactersLong));
public static Error DescriptionMustBeMaximum2000CharactersLong => Error.Validation(nameof(DescriptionMustBeMaximum2000CharactersLong));
public static Error GenresListCannotBeNull => Error.Validation(nameof(GenresListCannotBeNull));
public static Error GenreNameCannotBeEmpty => Error.Validation(nameof(GenreNameCannotBeEmpty));
public static Error GenreNameMustBeMaximum50CharactersLong => Error.Validation(nameof(GenreNameMustBeMaximum50CharactersLong));
public static Error TagsListCannotBeNull => Error.Validation(nameof(TagsListCannotBeNull));
public static Error TagNameCannotBeEmpty => Error.Validation(nameof(TagNameCannotBeEmpty));
public static Error TagNameMustBeMaximum50CharactersLong => Error.Validation(nameof(TagNameMustBeMaximum50CharactersLong));
public static Error LanguageCodeCannotBeEmpty => Error.Validation(nameof(LanguageCodeCannotBeEmpty));
public static Error LanguageNameCannotBeEmpty => Error.Validation(nameof(LanguageNameCannotBeEmpty));
public static Error LanguageCodeMustBe2CharactersLong => Error.Validation(nameof(LanguageCodeMustBe2CharactersLong));
public static Error LanguageNameMustBeMaximum50CharactersLong => Error.Validation(nameof(LanguageNameMustBeMaximum50CharactersLong));
public static Error LanguageNativeNameMustBeMaximum50CharactersLong => Error.Validation(nameof(LanguageNativeNameMustBeMaximum50CharactersLong));
public static Error OriginalReleaseYearMustBeBetween1And9999 => Error.Validation(nameof(OriginalReleaseYearMustBeBetween1And9999));
public static Error ReReleaseYearMustBeBetween1And9999 => Error.Validation(nameof(ReReleaseYearMustBeBetween1And9999));
public static Error ReReleaseYearCannotBeEarlierThanOriginalReleaseYear => Error.Validation(nameof(ReReleaseYearCannotBeEarlierThanOriginalReleaseYear));
public static Error CountryCodeMustBe2CharactersLong => Error.Validation(nameof(CountryCodeMustBe2CharactersLong));
public static Error ReleaseVersionMustBeMaximum50CharactersLong => Error.Validation(nameof(ReleaseVersionMustBeMaximum50CharactersLong));
public static Error OriginalReleaseDateAndYearMustMatch => Error.Validation(nameof(OriginalReleaseDateAndYearMustMatch));
public static Error ReReleaseDateAndYearMustMatch => Error.Validation(nameof(ReReleaseDateAndYearMustMatch));
public static Error ReReleaseDateCannotBeEarlierThanOriginalReleaseDate => Error.Validation(nameof(ReReleaseDateCannotBeEarlierThanOriginalReleaseDate));
public static Error ReleaseInfoCannotBeNull => Error.Validation(nameof(ReleaseInfoCannotBeNull));
public static Error RatingValueMustBePositive => Error.Validation(nameof(RatingValueMustBePositive));
public static Error RatingMaxValueMustBePositive => Error.Validation(nameof(RatingMaxValueMustBePositive));
public static Error RatingValueCannotBeGreaterThanMaxValue => Error.Validation(nameof(RatingValueCannotBeGreaterThanMaxValue));
public static Error RatingVoteCountMustBePositive => Error.Validation(nameof(RatingVoteCountMustBePositive));
public static Error RatingsListCannotBeNull => Error.Validation(nameof(RatingsListCannotBeNull));
public static Error InvalidIsoCode => Error.Validation(nameof(InvalidIsoCode));
public static Error MetadataCannotBeNull => Error.Validation(description: nameof(MetadataCannotBeNull));
public static Error TitleCannotBeEmpty => Error.Validation(description: nameof(TitleCannotBeEmpty));
public static Error TitleMustBeMaximum255CharactersLong => Error.Validation(description: nameof(TitleMustBeMaximum255CharactersLong));
public static Error OriginalTitleMustBeMaximum255CharactersLong => Error.Validation(description: nameof(OriginalTitleMustBeMaximum255CharactersLong));
public static Error DescriptionMustBeMaximum2000CharactersLong => Error.Validation(description: nameof(DescriptionMustBeMaximum2000CharactersLong));
public static Error GenresListCannotBeNull => Error.Validation(description: nameof(GenresListCannotBeNull));
public static Error GenreNameCannotBeEmpty => Error.Validation(description: nameof(GenreNameCannotBeEmpty));
public static Error GenreNameMustBeMaximum50CharactersLong => Error.Validation(description: nameof(GenreNameMustBeMaximum50CharactersLong));
public static Error TagsListCannotBeNull => Error.Validation(description: nameof(TagsListCannotBeNull));
public static Error TagNameCannotBeEmpty => Error.Validation(description: nameof(TagNameCannotBeEmpty));
public static Error TagNameMustBeMaximum50CharactersLong => Error.Validation(description: nameof(TagNameMustBeMaximum50CharactersLong));
public static Error LanguageCodeCannotBeEmpty => Error.Validation(description: nameof(LanguageCodeCannotBeEmpty));
public static Error LanguageNameCannotBeEmpty => Error.Validation(description: nameof(LanguageNameCannotBeEmpty));
public static Error LanguageCodeMustBe2CharactersLong => Error.Validation(description: nameof(LanguageCodeMustBe2CharactersLong));
public static Error LanguageNameMustBeMaximum50CharactersLong => Error.Validation(description: nameof(LanguageNameMustBeMaximum50CharactersLong));
public static Error LanguageNativeNameMustBeMaximum50CharactersLong => Error.Validation(description: nameof(LanguageNativeNameMustBeMaximum50CharactersLong));
public static Error OriginalReleaseYearMustBeBetween1And9999 => Error.Validation(description: nameof(OriginalReleaseYearMustBeBetween1And9999));
public static Error ReReleaseYearMustBeBetween1And9999 => Error.Validation(description: nameof(ReReleaseYearMustBeBetween1And9999));
public static Error ReReleaseYearCannotBeEarlierThanOriginalReleaseYear => Error.Validation(description: nameof(ReReleaseYearCannotBeEarlierThanOriginalReleaseYear));
public static Error CountryCodeMustBe2CharactersLong => Error.Validation(description: nameof(CountryCodeMustBe2CharactersLong));
public static Error ReleaseVersionMustBeMaximum50CharactersLong => Error.Validation(description: nameof(ReleaseVersionMustBeMaximum50CharactersLong));
public static Error OriginalReleaseDateAndYearMustMatch => Error.Validation(description: nameof(OriginalReleaseDateAndYearMustMatch));
public static Error ReReleaseDateAndYearMustMatch => Error.Validation(description: nameof(ReReleaseDateAndYearMustMatch));
public static Error ReReleaseDateCannotBeEarlierThanOriginalReleaseDate => Error.Validation(description: nameof(ReReleaseDateCannotBeEarlierThanOriginalReleaseDate));
public static Error ReleaseInfoCannotBeNull => Error.Validation(description: nameof(ReleaseInfoCannotBeNull));
public static Error RatingValueMustBePositive => Error.Validation(description: nameof(RatingValueMustBePositive));
public static Error RatingMaxValueMustBePositive => Error.Validation(description: nameof(RatingMaxValueMustBePositive));
public static Error RatingValueCannotBeGreaterThanMaxValue => Error.Validation(description: nameof(RatingValueCannotBeGreaterThanMaxValue));
public static Error RatingVoteCountMustBePositive => Error.Validation(description: nameof(RatingVoteCountMustBePositive));
public static Error RatingsListCannotBeNull => Error.Validation(description: nameof(RatingsListCannotBeNull));
public static Error InvalidIsoCode => Error.Validation(description: nameof(InvalidIsoCode));
}
}
@@ -11,6 +11,6 @@ public static partial class Errors
{
public static class Permission
{
public static Error UnauthorizedAccess => Error.Failure(nameof(UnauthorizedAccess));
public static Error UnauthorizedAccess => Error.Failure(description: nameof(UnauthorizedAccess));
}
}
@@ -11,7 +11,7 @@ public static partial class Errors
{
public static class Thumbnails
{
public static Error NoThumbnail => Error.Failure(nameof(NoThumbnail));
public static Error ImageQaulityMustBeBetweenZeroAndOneHundred => Error.Validation(nameof(ImageQaulityMustBeBetweenZeroAndOneHundred));
public static Error NoThumbnail => Error.Failure(description: nameof(NoThumbnail));
public static Error ImageQaulityMustBeBetweenZeroAndOneHundred => Error.Validation(description: nameof(ImageQaulityMustBeBetweenZeroAndOneHundred));
}
}
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
#endregion
namespace Lumina.Domain.Common.Errors;
/// <summary>
/// Users error types.
/// </summary>
public static partial class Errors
{
public static class Users
{
public static Error UserAlreadyExists => Error.Conflict(description: nameof(UserAlreadyExists));
public static Error UserDoesNotExist => Error.Conflict(description: nameof(UserDoesNotExist));
}
}
@@ -11,29 +11,29 @@ public static partial class Errors
{
public static class WrittenContent
{
public static Error BookAlreadyExists => Error.Conflict(nameof(BookAlreadyExists));
public static Error IsbnValueCannotBeEmpty => Error.Validation(nameof(IsbnValueCannotBeEmpty));
public static Error IsbnListCannotBeNull => Error.Validation(nameof(IsbnListCannotBeNull));
public static Error InvalidIsbn10Format => Error.Validation(nameof(InvalidIsbn10Format));
public static Error InvalidIsbn13Format => Error.Validation(nameof(InvalidIsbn13Format));
public static Error UnknownIsbnFormat => Error.Unexpected(nameof(UnknownIsbnFormat));
public static Error TheBookIsAlreadyInTheSeries => Error.Forbidden(nameof(TheBookIsAlreadyInTheSeries));
public static Error TheBookIsNotInTheSeries => Error.Forbidden(nameof(TheBookIsNotInTheSeries));
public static Error AsinMustBe10CharactersLong => Error.Validation(nameof(AsinMustBe10CharactersLong));
public static Error GoodreadsIdMustBeNumeric => Error.Validation(nameof(GoodreadsIdMustBeNumeric));
public static Error InvalidLccnFormat => Error.Validation(nameof(InvalidLccnFormat));
public static Error InvalidOclcFormat => Error.Validation(nameof(InvalidOclcFormat));
public static Error InvalidOpenLibraryId => Error.Validation(nameof(InvalidOpenLibraryId));
public static Error LibraryThingIdMustBeMaximum50CharactersLong => Error.Validation(nameof(LibraryThingIdMustBeMaximum50CharactersLong));
public static Error GoogleBooksIdMustBe12CharactersLong => Error.Validation(nameof(GoogleBooksIdMustBe12CharactersLong));
public static Error InvalidGoogleBooksIdFormat => Error.Validation(nameof(InvalidGoogleBooksIdFormat));
public static Error BarnesAndNoblesIdMustBe10CharactersLong => Error.Validation(nameof(BarnesAndNoblesIdMustBe10CharactersLong));
public static Error InvalidBarnesAndNoblesIdFormat => Error.Validation(nameof(InvalidBarnesAndNoblesIdFormat));
public static Error InvalidAppleBooksIdFormat => Error.Validation(nameof(InvalidAppleBooksIdFormat));
public static Error PublisherMustBeMaximum100CharactersLong => Error.Validation(nameof(PublisherMustBeMaximum100CharactersLong));
public static Error PageCountMustBeGreaterThanZero => Error.Validation(nameof(PageCountMustBeGreaterThanZero));
public static Error UnknownBookFormat => Error.Validation(nameof(UnknownBookFormat));
public static Error EditionMustBeMaximum50CharactersLong => Error.Validation(nameof(EditionMustBeMaximum50CharactersLong));
public static Error VolumeNumberMustBeGreaterThanZero => Error.Validation(nameof(VolumeNumberMustBeGreaterThanZero));
public static Error BookAlreadyExists => Error.Conflict(description: nameof(BookAlreadyExists));
public static Error IsbnValueCannotBeEmpty => Error.Validation(description: nameof(IsbnValueCannotBeEmpty));
public static Error IsbnListCannotBeNull => Error.Validation(description: nameof(IsbnListCannotBeNull));
public static Error InvalidIsbn10Format => Error.Validation(description: nameof(InvalidIsbn10Format));
public static Error InvalidIsbn13Format => Error.Validation(description: nameof(InvalidIsbn13Format));
public static Error UnknownIsbnFormat => Error.Unexpected(description: nameof(UnknownIsbnFormat));
public static Error TheBookIsAlreadyInTheSeries => Error.Forbidden(description: nameof(TheBookIsAlreadyInTheSeries));
public static Error TheBookIsNotInTheSeries => Error.Forbidden(description: nameof(TheBookIsNotInTheSeries));
public static Error AsinMustBe10CharactersLong => Error.Validation(description: nameof(AsinMustBe10CharactersLong));
public static Error GoodreadsIdMustBeNumeric => Error.Validation(description: nameof(GoodreadsIdMustBeNumeric));
public static Error InvalidLccnFormat => Error.Validation(description: nameof(InvalidLccnFormat));
public static Error InvalidOclcFormat => Error.Validation(description: nameof(InvalidOclcFormat));
public static Error InvalidOpenLibraryId => Error.Validation(description: nameof(InvalidOpenLibraryId));
public static Error LibraryThingIdMustBeMaximum50CharactersLong => Error.Validation(description: nameof(LibraryThingIdMustBeMaximum50CharactersLong));
public static Error GoogleBooksIdMustBe12CharactersLong => Error.Validation(description: nameof(GoogleBooksIdMustBe12CharactersLong));
public static Error InvalidGoogleBooksIdFormat => Error.Validation(description: nameof(InvalidGoogleBooksIdFormat));
public static Error BarnesAndNoblesIdMustBe10CharactersLong => Error.Validation(description: nameof(BarnesAndNoblesIdMustBe10CharactersLong));
public static Error InvalidBarnesAndNoblesIdFormat => Error.Validation(description: nameof(InvalidBarnesAndNoblesIdFormat));
public static Error InvalidAppleBooksIdFormat => Error.Validation(description: nameof(InvalidAppleBooksIdFormat));
public static Error PublisherMustBeMaximum100CharactersLong => Error.Validation(description: nameof(PublisherMustBeMaximum100CharactersLong));
public static Error PageCountMustBeGreaterThanZero => Error.Validation(description: nameof(PageCountMustBeGreaterThanZero));
public static Error UnknownBookFormat => Error.Validation(description: nameof(UnknownBookFormat));
public static Error EditionMustBeMaximum50CharactersLong => Error.Validation(description: nameof(EditionMustBeMaximum50CharactersLong));
public static Error VolumeNumberMustBeGreaterThanZero => Error.Validation(description: nameof(VolumeNumberMustBeGreaterThanZero));
}
}
@@ -1,4 +1,4 @@
namespace Lumina.Domain.Common.Models.Core;
namespace Lumina.Domain.Common.Models.Core;
/// <summary>
/// Base class for all domain Aggregate Roots.
@@ -15,7 +15,6 @@ public abstract class AggregateRoot<TId> : Entity<TId> where TId : notnull
Id = id;
}
#pragma warning disable CS8618
/// <summary>
/// Initializes a new instance of the <see cref="AggregateRoot{TId}"/> class.
/// </summary>
@@ -23,5 +22,4 @@ public abstract class AggregateRoot<TId> : Entity<TId> where TId : notnull
{
}
#pragma warning restore CS8618
}
}
@@ -23,12 +23,12 @@ public abstract class BaseMetadata : ValueObject
public string Title { get; private set; }
/// <summary>
/// Gets the original title of the media item.
/// Gets the original title of the media item, if applicable.
/// </summary>
public Optional<string> OriginalTitle { get; private set; }
/// <summary>
/// Gets the optional description of the media item.
/// Gets the optional description of the media item, if applicable.
/// </summary>
public Optional<string> Description { get; private set; }
@@ -38,12 +38,12 @@ public abstract class BaseMetadata : ValueObject
public ReleaseInfo ReleaseInfo { get; private set; }
/// <summary>
/// Gets the optional language of the media item.
/// Gets the optional language of the media item, if applicable.
/// </summary>
public Optional<LanguageInfo> Language { get; private set; }
/// <summary>
/// Gets the optional original language of the media item.
/// Gets the optional original language of the media item, if applicable.
/// </summary>
public Optional<LanguageInfo> OriginalLanguage { get; private set; }
@@ -61,13 +61,13 @@ public abstract class BaseMetadata : ValueObject
/// 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>
/// <param name="description">The optional description 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, if applicable.</param>
/// <param name="description">The optional description of the element to which this metadata object belongs to, if applicable.</param>
/// <param name="releaseInfo">The optional release information of the media item.</param>
/// <param name="genres">The list of genres of the element to which this metadata object belongs to.</param>
/// <param name="tags">The list of tags of the element to which this metadata object belongs to.</param>
/// <param name="language">The optional language of the element to which this metadata object belongs to.</param>
/// <param name="originalLanguage">The optional original language of the element to which this metadata object belongs to.</param>
/// <param name="language">The optional language of the element to which this metadata object belongs to, if applicable.</param>
/// <param name="originalLanguage">The optional original language of the element to which this metadata object belongs to, if applicable.</param>
/// <exception cref="ArgumentNullException">Thrown when the <see cref="title"/> value is <see langword="null"/></exception>
protected BaseMetadata(
string title,
@@ -103,4 +103,4 @@ public abstract class BaseMetadata : ValueObject
yield return Language;
yield return OriginalLanguage;
}
}
}
@@ -34,7 +34,7 @@ public class Genre : ValueObject
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Genre"/>, or an error message.
/// </returns>
public static ErrorOr<Genre> Create(string name)
public static ErrorOr<Genre> Create(string? name)
{
if (string.IsNullOrWhiteSpace(name))
return Errors.Errors.Metadata.GenreNameCannotBeEmpty;
@@ -51,7 +51,7 @@ public class LanguageInfo : ValueObject
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LanguageInfo"/>, or an error message.
/// </returns>
public static ErrorOr<LanguageInfo> Create(string languageCode, string languageName, Optional<string> nativeName)
public static ErrorOr<LanguageInfo> Create(string? languageCode, string? languageName, Optional<string> nativeName)
{
if (string.IsNullOrWhiteSpace(languageCode))
return Errors.Errors.Metadata.LanguageCodeCannotBeEmpty;
@@ -34,7 +34,7 @@ public class Tag : ValueObject
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Tag"/>, or an error message.
/// </returns>
public static ErrorOr<Tag> Create(string name)
public static ErrorOr<Tag> Create(string? name)
{
if (string.IsNullOrWhiteSpace(name))
return Errors.Errors.Metadata.TagNameCannotBeEmpty;
@@ -1,22 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
/// <summary>
/// Interface for defining the contract of a platform-specific context.
/// </summary>
public interface IPlatformContext
{
/// <summary>
/// Gets the platform for the current platform context.
/// </summary>
PlatformType Platform { get; }
/// <summary>
/// Gets the path strategy for the current platform context.
/// </summary>
IPathStrategy PathStrategy { get; }
}
@@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.AudioLibrary.AudioLibraryAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.AudioLibraryAggregate.ValueObjects;
/// <summary>
/// Value Object for the audio metadata of a media element.
@@ -150,4 +150,4 @@ public class AudioMetadata : BaseMetadata
yield return AudioCodec;
yield return Bitrate;
}
}
}
@@ -1,14 +1,15 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
/// <summary>
/// Entity representing a file system directory.
@@ -1,14 +1,15 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
/// <summary>
/// Entity representing a file system file.
@@ -144,7 +145,7 @@ public sealed class File : FileSystemItem
public ErrorOr<Updated> Rename(string newName)
{
if (string.IsNullOrWhiteSpace(newName))
return Errors.FileManagement.NameCannotBeEmpty;
return Errors.FileSystemManagement.NameCannotBeEmpty;
Name = newName;
return Result.Updated;
}
@@ -1,12 +1,13 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
/// <summary>
/// Entity representing a file system root item on Unix platforms.
@@ -38,15 +39,12 @@ public sealed class UnixRootItem : FileSystemItem
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="UnixRootItem"/>, or an error message.
/// </returns>
public static ErrorOr<UnixRootItem> Create(
FileSystemItemStatus status = FileSystemItemStatus.Accessible)
public static ErrorOr<UnixRootItem> Create(FileSystemItemStatus status = FileSystemItemStatus.Accessible)
{
ErrorOr<FileSystemPathId> createPathResult = FileSystemPathId.Create(PATH);
if (createPathResult.IsError)
return createPathResult.Errors;
UnixRootItem newRoot = new(
createPathResult.Value,
PATH);
UnixRootItem newRoot = new(createPathResult.Value, PATH);
ErrorOr<Updated> setStatusResult = newRoot.SetStatus(status);
if (setStatusResult.IsError)
return setStatusResult.Errors;
@@ -1,12 +1,13 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
/// <summary>
/// Entity representing a file system root item on Windows platforms.
@@ -1,14 +1,14 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
/// <summary>
/// Entity representing a generic file system element.
@@ -69,7 +69,7 @@ public abstract class FileSystemItem : AggregateRoot<FileSystemPathId>
if (parent is not null)
Parent = parent;
else
return Errors.FileManagement.ParentNodeCannotBeNull;
return Errors.FileSystemManagement.ParentNodeCannotBeNull;
return Result.Updated;
}
}
}
@@ -1,9 +1,10 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.IO;
@@ -11,7 +12,7 @@ using System.IO.Abstractions;
using System.Linq;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Directory provider for local file systems.
@@ -146,7 +147,7 @@ internal class DirectoryProviderService : IDirectoryProviderService
{
// check if the source directory exists
if (!_fileSystem.Directory.Exists(sourcePath.Path))
return Errors.FileManagement.DirectoryNotFound;
return Errors.FileSystemManagement.DirectoryNotFound;
string destPath = CreateUniqueDirectoryPath(destinationPath.Path);
try
{
@@ -179,7 +180,7 @@ internal class DirectoryProviderService : IDirectoryProviderService
}
catch
{
return Errors.FileManagement.DirectoryCopyError;
return Errors.FileSystemManagement.DirectoryCopyError;
}
}
@@ -209,7 +210,7 @@ internal class DirectoryProviderService : IDirectoryProviderService
{
// check if the source directory exists
if (!_fileSystem.Directory.Exists(sourcePath.Path))
return Errors.FileManagement.DirectoryNotFound;
return Errors.FileSystemManagement.DirectoryNotFound;
try
{
// if the destination directory does not exist, perform a simple move
@@ -221,7 +222,7 @@ internal class DirectoryProviderService : IDirectoryProviderService
}
catch
{
return Errors.FileManagement.DirectoryMoveError;
return Errors.FileSystemManagement.DirectoryMoveError;
}
}
@@ -247,7 +248,6 @@ internal class DirectoryProviderService : IDirectoryProviderService
_fileSystem.File.Delete(destFilePath);
_fileSystem.File.Move(sourceFilePath, destFilePath);
}
// otherwise, skip the file
}
else
_fileSystem.File.Move(sourceFilePath, destFilePath); // move the file if it does not exist in the destination directory
@@ -298,10 +298,10 @@ internal class DirectoryProviderService : IDirectoryProviderService
return newDirectoryPathResult.Value;
}
else
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
}
else
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
}
/// <summary>
@@ -1,17 +1,17 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Service for handling directories.
@@ -131,7 +131,7 @@ public class DirectoryService : IDirectoryService
if (directoryExists.IsError)
return directoryExists.Errors;
else if (directoryExists.Value == true)
return Errors.FileManagement.DirectoryAlreadyExists;
return Errors.FileSystemManagement.DirectoryAlreadyExists;
else
{
// create the new directory
@@ -195,7 +195,7 @@ public class DirectoryService : IDirectoryService
if (directoryExists.IsError)
return directoryExists.Errors;
else if (directoryExists.Value == false)
return Errors.FileManagement.DirectoryNotFound;
return Errors.FileSystemManagement.DirectoryNotFound;
else
{
// copy the directory
@@ -241,7 +241,7 @@ public class DirectoryService : IDirectoryService
if (directoryExists.IsError)
return directoryExists.Errors;
else if (directoryExists.Value == false)
return Errors.FileManagement.DirectoryNotFound;
return Errors.FileSystemManagement.DirectoryNotFound;
else
{
// move the directory
@@ -281,7 +281,7 @@ public class DirectoryService : IDirectoryService
if (directoryExists.IsError)
return directoryExists.Errors;
else if (directoryExists.Value == true)
return Errors.FileManagement.DirectoryAlreadyExists;
return Errors.FileSystemManagement.DirectoryAlreadyExists;
else
{
// rename the directory
@@ -1,14 +1,16 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using System.Collections.Generic;
using System.IO.Abstractions;
using System.Linq;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Service for handling drives.
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.IO;
@@ -11,7 +11,7 @@ using System.IO.Abstractions;
using System.Linq;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// File provider for local file systems.
@@ -153,19 +153,17 @@ internal class FileProviderService : IFileProviderService
{
// check if the source file exists
if (!_fileSystem.File.Exists(sourceFilePath.Path))
return Errors.FileManagement.FileNotFound;
return Errors.FileSystemManagement.FileNotFound;
string fileName = _fileSystem.Path.GetFileName(sourceFilePath.Path);
string destinationFilePath = _fileSystem.Path.Combine(destinationDirectoryPath.Path, fileName);
// when copying a file to the same location, just copy it with a new name
if (_fileSystem.Path.GetDirectoryName(sourceFilePath.Path) == destinationDirectoryPath.Path)
destinationFilePath = CreateUniqueFilePath(destinationFilePath);
else
{
// check if there is already a file with the same name as the copied file, in the destination directory
if (_fileSystem.File.Exists(destinationFilePath))
if (!overrideExisting)
return Errors.FileManagement.FileAlreadyExists;
}
if (!overrideExisting)
return Errors.FileSystemManagement.FileAlreadyExists;
try
{
_fileSystem.File.Copy(sourceFilePath.Path, destinationFilePath, overrideExisting); // copy the file
@@ -174,7 +172,7 @@ internal class FileProviderService : IFileProviderService
}
catch
{
return Errors.FileManagement.FileCopyError;
return Errors.FileSystemManagement.FileCopyError;
}
}
@@ -208,7 +206,7 @@ internal class FileProviderService : IFileProviderService
{
// check if the source file exists
if (!_fileSystem.File.Exists(sourceFilePath.Path))
return Errors.FileManagement.FileNotFound;
return Errors.FileSystemManagement.FileNotFound;
try
{
string fileName = _fileSystem.Path.GetFileName(sourceFilePath.Path);
@@ -217,17 +215,15 @@ internal class FileProviderService : IFileProviderService
if (!_fileSystem.File.Exists(destinationFilePath))
_fileSystem.File.Move(sourceFilePath.Path, destinationFilePath);
else
{
if (overrideExisting)
_fileSystem.File.Move(sourceFilePath.Path, destinationFilePath, overrideExisting);
else
return Errors.FileManagement.FileAlreadyExists;
}
_fileSystem.File.Move(sourceFilePath.Path, destinationFilePath, overrideExisting);
else
return Errors.FileSystemManagement.FileAlreadyExists;
return FileSystemPathId.Create(destinationFilePath);
}
catch
{
return Errors.FileManagement.FileMoveError;
return Errors.FileSystemManagement.FileMoveError;
}
}
@@ -260,10 +256,10 @@ internal class FileProviderService : IFileProviderService
return newFilePathResult;
}
else
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
}
else
return Errors.FileManagement.CannotNavigateUp;
return Errors.FileSystemManagement.CannotNavigateUp;
}
/// <summary>
@@ -1,17 +1,17 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Service for handling file system files.
@@ -113,7 +113,7 @@ public class FileService : IFileService
public ErrorOr<File> CopyFile(string sourceFilePath, string destinationDirectoryPath, bool? overrideExisting)
{
if (string.IsNullOrWhiteSpace(destinationDirectoryPath))
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
// make sure the paths are in the expected format
if (!destinationDirectoryPath.EndsWith(_platformContext.PathStrategy.PathSeparator))
destinationDirectoryPath += _platformContext.PathStrategy.PathSeparator;
@@ -139,7 +139,7 @@ public class FileService : IFileService
if (fileExists.IsError)
return fileExists.Errors;
else if (fileExists.Value == false)
return Errors.FileManagement.FileNotFound;
return Errors.FileSystemManagement.FileNotFound;
else
{
// copy the file
@@ -179,7 +179,7 @@ public class FileService : IFileService
public ErrorOr<File> MoveFile(string sourceFilePath, string destinationDirectoryPath, bool? overrideExisting)
{
if (string.IsNullOrWhiteSpace(destinationDirectoryPath))
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
// make sure the paths are in the expected format
if (!destinationDirectoryPath.EndsWith(_platformContext.PathStrategy.PathSeparator))
destinationDirectoryPath += _platformContext.PathStrategy.PathSeparator;
@@ -205,7 +205,7 @@ public class FileService : IFileService
if (fileExists.IsError)
return fileExists.Errors;
else if (fileExists.Value == false)
return Errors.FileManagement.FileNotFound;
return Errors.FileSystemManagement.FileNotFound;
else
{
// move the file
@@ -265,7 +265,7 @@ public class FileService : IFileService
if (fileExists.IsError)
return fileExists.Errors;
else if (fileExists.Value == true)
return Errors.FileManagement.FileAlreadyExists;
return Errors.FileSystemManagement.FileAlreadyExists;
else
{
// rename the file
@@ -1,9 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Mono.Unix;
using Mono.Unix.Native;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System;
using System.IO;
using System.Runtime.Versioning;
@@ -11,7 +9,7 @@ using System.Security.AccessControl;
using System.Security.Principal;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Service for file system permissions.
@@ -40,7 +38,7 @@ internal class FileSystemPermissionsService : IFileSystemPermissionsService // T
{
PlatformType platformType = _platformContextManager.GetCurrentContext().Platform;
if (platformType == PlatformType.Unix)
return CanAccessPathLinux(path.Path, accessMode);
return CanAccessPathUnix(path.Path, accessMode);
else if (platformType == PlatformType.Windows)
#pragma warning disable CA1416 // Validate platform compatibility
return CanAccessPathWindows(path.Path, accessMode, isFile);
@@ -50,51 +48,99 @@ internal class FileSystemPermissionsService : IFileSystemPermissionsService // T
}
/// <summary>
/// Checks if a the current user has access permissions on Linux for <paramref name="path"/>, with <paramref name="accessMode"/>.
/// Checks if a the current user has access permissions on Unix for <paramref name="path"/>, with <paramref name="accessMode"/>.
/// </summary>
/// <param name="path">The path for which to check the access.</param>
/// <param name="accessMode">The access mode in which to check that path access.</param>
/// <returns><see langword="true"/> if the current user has rights for the specified path and acccess mode, <see langword="false"/> otherwise.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown when trying to check access for a mode that is not supported</exception>
private static bool CanAccessPathLinux(string path, FileAccessMode accessMode)
/// <exception cref="ArgumentOutOfRangeException">Thrown when trying to check access for a mode that is not supported.</exception>
private static bool CanAccessPathUnix(string path, FileAccessMode accessMode)
{
AccessModes modes;
UnixFileSystemInfo fileInfo = new UnixFileInfo(path);
switch (accessMode)
try
{
case FileAccessMode.ReadProperties:
// we would typically need execute permissions on a directory, to list its contents or view file properties
if (fileInfo.FileType == FileTypes.Directory)
return fileInfo.CanAccess(AccessModes.X_OK);
// for files, just verifying existence might be sufficient for reading properties
return fileInfo.Exists;
case FileAccessMode.ReadContents:
return fileInfo.CanAccess(AccessModes.R_OK);
case FileAccessMode.Write:
modes = AccessModes.W_OK;
break;
case FileAccessMode.Execute:
modes = AccessModes.X_OK;
break;
case FileAccessMode.ListDirectory:
modes = AccessModes.F_OK; // check existence, not an exact match but the closest
break;
case FileAccessMode.Delete:
if (fileInfo.FileType == FileTypes.Directory)
return fileInfo.CanAccess(AccessModes.W_OK | AccessModes.X_OK); // to delete a directory, we need write and execute permissions on the directory itself
else
{
// to delete a file, we need write permission on the parent directory
string? parentDirectoryPath = Path.GetDirectoryName(path);
if (string.IsNullOrEmpty(parentDirectoryPath))
return false; // if path is a root directory or has no parent, deletion is not possible
UnixDirectoryInfo parentDirectoryInfo = new(parentDirectoryPath);
return parentDirectoryInfo.CanAccess(AccessModes.W_OK);
}
default:
throw new ArgumentOutOfRangeException(nameof(accessMode), "Unknown FileAccessMode");
switch (accessMode)
{
case FileAccessMode.ReadProperties:
// for properties, we only need to check if the path exists
return File.Exists(path) || Directory.Exists(path);
case FileAccessMode.ReadContents:
// attempt to open the file for reading to verify read access
if (File.Exists(path))
{
FileStream fileStream = File.OpenRead(path);
fileStream.Dispose();
return true;
}
return false;
case FileAccessMode.Write:
// attempt to open the file for writing or verify directory exists
if (File.Exists(path))
{
FileStream fileStream = File.OpenWrite(path);
fileStream.Dispose();
return true;
}
return Directory.Exists(path);
case FileAccessMode.Execute:
// check Unix execute permission bit
FileInfo fileInfo = new(path);
return (fileInfo.UnixFileMode & UnixFileMode.UserExecute) != 0;
case FileAccessMode.ListDirectory:
// attempt to list directory contents to verify access
if (Directory.Exists(path))
{
string[] _ = Directory.GetFiles(path);
return true;
}
return false;
case FileAccessMode.Delete:
if (File.Exists(path))
{
// for files, check if parent directory is writable
string? directoryPath = Path.GetDirectoryName(path);
return directoryPath != null && HasWriteAccessToDirectory(directoryPath);
}
// for directories, check if the directory itself is writable
return Directory.Exists(path) && HasWriteAccessToDirectory(path);
default:
throw new ArgumentOutOfRangeException(nameof(accessMode), "Unknown FileAccessMode");
}
}
catch (UnauthorizedAccessException)
{
return false; // access denied by the operating system
}
catch (IOException)
{
return false; // IO operation failed, indicating no access
}
}
/// <summary>
/// Verifies write access to a directory by attempting to create and delete a temporary file.
/// </summary>
/// <param name="path">The directory path to check for write access.</param>
/// <returns><see langword="true"/> if write access is granted, <see langword="false"/> otherwise.</returns>
private static bool HasWriteAccessToDirectory(string path)
{
try
{
// create a unique temporary filename
string temporaryFilePath = Path.Combine(path, string.Format(".test_{0}", Guid.NewGuid()));
// attempt to create and immediately delete a temporary file
FileStream testStream = File.Create(temporaryFilePath);
testStream.Dispose();
File.Delete(temporaryFilePath);
return true;
}
catch (UnauthorizedAccessException)
{
return false;
}
catch (IOException)
{
return false;
}
return new UnixDirectoryInfo(path).CanAccess(modes);
}
/// <summary>
@@ -129,31 +175,27 @@ internal class FileSystemPermissionsService : IFileSystemPermissionsService // T
return HasAccess(FileSystemRights.Modify, parentDirectory, false);
}
else
{
if (HasAccess(rights, path, isFile))
try
{
try
switch (accessMode)
{
switch (accessMode)
{
case FileAccessMode.ReadProperties:
// just accessing file info for properties, without opening it
FileSystemInfo fileSystemInfo = isFile ? new FileInfo(path) : new DirectoryInfo(path);
_ = fileSystemInfo.CreationTime; // trigger potential access denial
break;
case FileAccessMode.ReadContents:
using (FileStream stream = new(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
stream.Close();
break;
}
return true;
}
catch
{
return false;
case FileAccessMode.ReadProperties:
// just accessing file info for properties, without opening it
FileSystemInfo fileSystemInfo = isFile ? new FileInfo(path) : new DirectoryInfo(path);
_ = fileSystemInfo.CreationTime; // trigger potential access denial
break;
case FileAccessMode.ReadContents:
using (FileStream stream = new(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
stream.Close();
break;
}
return true;
}
catch
{
return false;
}
}
return false;
}
@@ -186,16 +228,12 @@ internal class FileSystemPermissionsService : IFileSystemPermissionsService // T
acl = directoryInfo.GetAccessControl().GetAccessRules(true, true, typeof(SecurityIdentifier));
}
foreach (FileSystemAccessRule accessRule in acl)
{
// Check if the current rule applies to the current user or the groups they belong to
if (identity?.User?.Equals(accessRule.IdentityReference) == true || principal.IsInRole((SecurityIdentifier)accessRule.IdentityReference))
{
if (accessRule.AccessControlType.Equals(AccessControlType.Deny) && (accessRule.FileSystemRights & rights) == rights)
return false; // if there's a deny rule that matches the specified rights, return false immediately
else if (accessRule.AccessControlType.Equals(AccessControlType.Allow) && (accessRule.FileSystemRights & rights) == rights)
allowAccess = true;
}
}
}
catch
@@ -1,10 +1,10 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Contracts.Enums.PhotoLibrary;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Common.Enums.PhotoLibrary;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using System;
using System.IO.Abstractions;
using System.Linq;
@@ -13,7 +13,7 @@ using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Class defining methods for handling file-related operations.
@@ -1,12 +1,12 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Interface defining the directory provider service.
@@ -1,11 +1,11 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Interface for the service for handling directories.
@@ -1,9 +1,10 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Interface for the service for handling drives.
@@ -15,4 +16,4 @@ public interface IDriveService
/// </summary>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a collection of drives or an error.</returns>
ErrorOr<IEnumerable<FileSystemItem>> GetDrives();
}
}
@@ -1,12 +1,12 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Interface defining the file provider service.
@@ -95,4 +95,4 @@ public interface IFileProviderService
/// <param name="path">The path of the file to be deleted.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either the result of deleting a file, or an error.</returns>
ErrorOr<Deleted> DeleteFile(FileSystemPathId path);
}
}
@@ -1,11 +1,11 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Interface for the service for handling file system files.
@@ -68,4 +68,4 @@ public interface IFileService
/// <param name="path">String representation of the file path.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either the result of deleting a file, or an error.</returns>
ErrorOr<Deleted> DeleteFile(string path);
}
}
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Interface for file system permission service.
@@ -18,4 +18,4 @@ public interface IFileSystemPermissionsService
/// <param name="isFile">Indicates whether the path represents a file or directory.</param>
/// <returns><see langword="true"/>, if <paramref name="path"/> can be accessed, <see langword="false"/> otherwise.</returns>
bool CanAccessPath(FileSystemPathId path, FileAccessMode accessMode, bool isFile = true);
}
}
@@ -1,13 +1,13 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.PhotoLibrary;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Common.Enums.PhotoLibrary;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Interface defining methods for handling file-related operations based on different sources.
@@ -1,10 +1,10 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Interface for the service for handling file system paths.
@@ -1,11 +1,11 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Interface for the service for handling thumbnails.
@@ -1,12 +1,12 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Service defining methods for handling path-related operations.
@@ -65,7 +65,7 @@ public class PathService : IPathService
public ErrorOr<string> CombinePath(string path, string name)
{
if (string.IsNullOrWhiteSpace(path) || string.IsNullOrWhiteSpace(name))
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
ErrorOr<FileSystemPathId> newPathResult = FileSystemPathId.Create(path);
if (newPathResult.IsError)
return newPathResult.Errors;
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.PhotoLibrary;
using Lumina.Domain.Common.Enums.PhotoLibrary;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Png;
@@ -14,7 +14,7 @@ using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
/// <summary>
/// Service for handling thumbnails.
@@ -1,8 +1,8 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Environment;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
/// <summary>
/// Represents the context for environment-specific operations and services.
@@ -1,8 +1,8 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Environment;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
/// <summary>
/// Interface for defining the contract of an environment-specific context, encapsulating all platform-specific services and strategies.
@@ -23,4 +23,4 @@ public interface IEnvironmentContext
/// Gets the service for providing file system directories.
/// </summary>
IDirectoryProviderService DirectoryProviderService { get; }
}
}
@@ -1,10 +1,10 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
/// <summary>
/// Interface defining methods for handling path-related operations based on different platforms.
@@ -1,8 +1,8 @@
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
/// <summary>
/// Interface defining methods for handling path-related operations on UNIX platforms.
/// </summary>
public interface IUnixPathStrategy : IPathStrategy
{
}
}
@@ -1,8 +1,8 @@
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
/// <summary>
/// Interface defining methods for handling path-related operations on Windows platforms.
/// </summary>
public interface IWindowsPathStrategy : IPathStrategy
{
}
}
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.IO;
@@ -10,7 +10,7 @@ using System.Linq;
using System.Text.RegularExpressions;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
/// <summary>
/// Service defining methods for handling path-related operations on UNIX platforms.
@@ -83,7 +83,7 @@ public class UnixPathStrategy : IUnixPathStrategy
public ErrorOr<FileSystemPathId> CombinePath(FileSystemPathId path, string name)
{
if (string.IsNullOrWhiteSpace(name))
return Errors.FileManagement.NameCannotBeEmpty;
return Errors.FileSystemManagement.NameCannotBeEmpty;
// trim any directory separator characters from the end of the path
string subpath = path.Path.TrimEnd(PathSeparator);
// if the name begins with a directory separator, remove it
@@ -101,7 +101,7 @@ public class UnixPathStrategy : IUnixPathStrategy
{
// if path starts with anything other than '/', it's considered relative and invalid for this parser
if (!path.Path.StartsWith(PathSeparator))
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
// get the path segments
List<string> splitSegments = [.. path.Path.Split(new[] { PathSeparator }, StringSplitOptions.RemoveEmptyEntries)];
IEnumerable<ErrorOr<PathSegment>> segmentsResults = splitSegments.Select((segment, index) =>
@@ -128,7 +128,7 @@ public class UnixPathStrategy : IUnixPathStrategy
{
// validation: ensure the path is not null or empty
if (!IsValidPath(path))
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
// trim trailing slash for consistent processing
string tempPath = path.Path;
if (tempPath.EndsWith('/'))
@@ -137,7 +137,7 @@ public class UnixPathStrategy : IUnixPathStrategy
int lastIndex = tempPath.LastIndexOf(PathSeparator);
// if there's no slash found (shouldn't happen due to previous steps), or if we are at the root level after trimming, return error
if (lastIndex < 0)
return Errors.FileManagement.CannotNavigateUp;
return Errors.FileSystemManagement.CannotNavigateUp;
// return the path up to the last slash, or, if there's only the root slash, return that one instead
ErrorOr<FileSystemPathId> newPathResult = FileSystemPathId.Create(lastIndex > 0 ? tempPath[..lastIndex] : tempPath[..1]);
if (newPathResult.IsError)
@@ -162,11 +162,11 @@ public class UnixPathStrategy : IUnixPathStrategy
public ErrorOr<PathSegment> GetPathRoot(FileSystemPathId path)
{
if (!IsValidPath(path))
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
// On Unix-like systems, the root is always "/"
if (path.Path.StartsWith(PathSeparator))
return PathSegment.Create(PathSeparator.ToString(), isDirectory: false, isDrive: true);
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
}
}
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.IO;
@@ -10,7 +10,7 @@ using System.Linq;
using System.Text.RegularExpressions;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
/// <summary>
/// Service defining methods for handling path-related operations on Windows platforms.
@@ -36,14 +36,14 @@ public class WindowsPathStrategy : IWindowsPathStrategy
/// <param name="path">The path to be checked.</param>
/// <returns><see langword="true"/> if <paramref name="path"/> is a valid path, <see langword="false"/> otherwise.</returns>
public bool IsValidPath(FileSystemPathId path)
{
{
// check for invalid path characters
char[] invalidChars = GetInvalidPathCharsForPlatform();
if (path.Path.IndexOfAny(invalidChars) >= 0)
return false;
// regular expression to match valid absolute paths
// this allows drive letters (e.g., C:\) and UNC paths (e.g., \\server\share)
const string PATH_PATTERN = @"^(?:[a-zA-Z]:\\|\\\\[a-zA-Z0-9\s()._\[\]-]+\\[a-zA-Z0-9\s()._\[\]-]+)(?:[a-zA-Z0-9\s()._\[\]-]+\\)*[a-zA-Z0-9\s()._\[\]-]*\\?$";
const string PATH_PATTERN = @"^(?:[a-zA-Z]:\\|\\\\[a-zA-Z0-9\s()._&+,\[\]-]+\\[a-zA-Z0-9\s()._&+,\[\]-]+)(?:[a-zA-Z0-9\s()._&+,\[\]-]+\\)*[a-zA-Z0-9\s()._&+,\[\]-]*\\?$";
return Regex.IsMatch(path.Path, PATH_PATTERN);
}
@@ -82,7 +82,7 @@ public class WindowsPathStrategy : IWindowsPathStrategy
public ErrorOr<FileSystemPathId> CombinePath(FileSystemPathId path, string name)
{
if (name == null)
return Errors.FileManagement.NameCannotBeEmpty;
return Errors.FileSystemManagement.NameCannotBeEmpty;
// trim any directory separator characters from the end of the path
string subpath = path.Path.TrimEnd(PathSeparator);
// if the name begins with a directory separator, remove it
@@ -100,7 +100,7 @@ public class WindowsPathStrategy : IWindowsPathStrategy
{
// Windows paths usually start with a drive letter and colon, e.g., "C:", or "\\" (UNC paths)
if (!(path.Path.StartsWith(@"\\") || (path.Path.Length >= 3 && char.IsLetter(path.Path[0]) && path.Path[1] == ':' && path.Path[2] == PathSeparator)))
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
IEnumerable<ErrorOr<PathSegment>> getPathSegmentsResults = GetPathSegments();
foreach (ErrorOr<PathSegment> getPathSegmentsResult in getPathSegmentsResults)
if (getPathSegmentsResult.IsError)
@@ -153,7 +153,7 @@ public class WindowsPathStrategy : IWindowsPathStrategy
{
// validation: ensure the path is not null or empty
if (!IsValidPath(path))
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
// trim trailing backslash for consistent processing
string tempPath = path.Path.TrimEnd(PathSeparator);
// check for UNC path
@@ -161,13 +161,13 @@ public class WindowsPathStrategy : IWindowsPathStrategy
{
string[] parts = tempPath.Split(PathSeparator, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length <= 2)
return Errors.FileManagement.CannotNavigateUp;
return Errors.FileSystemManagement.CannotNavigateUp;
// if it's a single-level UNC path, return the UNC root
if (parts.Length == 3)
return ParsePath(FileSystemPathId.Create($@"\\{parts[0]}\{parts[1]}").Value);
} // check for drive root (both with and without trailing backslash)
else if ((tempPath.Length == 2 && tempPath[1] == ':') || (tempPath.Length == 3 && tempPath[1] == ':' && tempPath[2] == PathSeparator))
return Errors.FileManagement.CannotNavigateUp;
return Errors.FileSystemManagement.CannotNavigateUp;
// find the last occurrence of a backslash
int lastIndex = tempPath.LastIndexOf(PathSeparator);
// if there's no backslash found or it's at the root level, return the root
@@ -198,14 +198,14 @@ public class WindowsPathStrategy : IWindowsPathStrategy
public ErrorOr<PathSegment> GetPathRoot(FileSystemPathId path)
{
if (!IsValidPath(path))
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
// handle UNC paths (e.g., \\server\share\folder)
if (path.Path.StartsWith(@"\\"))
{
// find the position of the second backslash (after \\server)
int secondBackslash = path.Path.IndexOf('\\', 2);
if (secondBackslash == -1)
return Errors.FileManagement.InvalidPath; // invalid UNC path, missing server name
return Errors.FileSystemManagement.InvalidPath; // invalid UNC path, missing server name
// find the position of the third backslash (after \\server\share)
int thirdBackslash = path.Path.IndexOf('\\', secondBackslash + 1);
if (thirdBackslash == -1)
@@ -214,15 +214,13 @@ public class WindowsPathStrategy : IWindowsPathStrategy
return PathSegment.Create(path.Path[..thirdBackslash] + "\\", isDirectory: true, isDrive: false);
}
else // handle drive letter paths (e.g., C:\folder)
{
// check if the path starts with a drive letter followed by a colon (e.g., C:)
// path.Path.Length >= 2: Ensure the path is at least 2 characters long
// char.IsLetter(path.Path[0]): First character should be a letter
// path.Path[1] == ':': Second character should be a colon
if (path.Path.Length >= 2 && char.IsLetter(path.Path[0]) && path.Path[1] == ':')
return PathSegment.Create(path.Path[..2] + "\\", isDirectory: true, isDrive: true); // return the drive root (e.g., C:\)
}
// check if the path starts with a drive letter followed by a colon (e.g., C:)
// path.Path.Length >= 2: Ensure the path is at least 2 characters long
// char.IsLetter(path.Path[0]): First character should be a letter
// path.Path[1] == ':': Second character should be a colon
if (path.Path.Length >= 2 && char.IsLetter(path.Path[0]) && path.Path[1] == ':')
return PathSegment.Create(path.Path[..2] + "\\", isDirectory: true, isDrive: true); // return the drive root (e.g., C:\)
// if we reach here, the path is neither a valid UNC path nor a valid drive path
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
}
}
@@ -2,7 +2,7 @@
using System.Runtime.InteropServices;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
/// <summary>
/// Interface for checking the type of the current Operating System platform.
@@ -0,0 +1,22 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
#endregion
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
/// <summary>
/// Interface for defining the contract of a platform-specific context.
/// </summary>
public interface IPlatformContext
{
/// <summary>
/// Gets the platform for the current platform context.
/// </summary>
PlatformType Platform { get; }
/// <summary>
/// Gets the path strategy for the current platform context.
/// </summary>
IPathStrategy PathStrategy { get; }
}
@@ -1,4 +1,4 @@
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
/// <summary>
/// Interface defining an factory for creating platform contexts.
@@ -11,4 +11,4 @@ public interface IPlatformContextFactory
/// <typeparam name="TIPlatformContext">The type of platform context to create.</typeparam>
/// <returns>The created platform context.</returns>
TIPlatformContext CreateStrategy<TIPlatformContext>() where TIPlatformContext : IPlatformContext;
}
}
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Enums.FileSystem;
using System;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
/// <summary>
/// Interface for managing the platform context.
@@ -22,4 +22,4 @@ public interface IPlatformContextManager
/// <param name="platformType">The platform to be set.</param>
/// <exception cref="ArgumentException">Thrown when an unsupported platform type is provided.</exception>
void SetCurrentPlatform(PlatformType platformType);
}
}
@@ -1,8 +1,8 @@
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
/// <summary>
/// Interface defining the platform context for UNIX platforms.
/// </summary>
public interface IUnixPlatformContext : IPlatformContext
{
}
}
@@ -1,8 +1,8 @@
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
/// <summary>
/// Interface defining the platform context for Windows platforms.
/// </summary>
internal interface IWindowsPlatformContext : IPlatformContext
{
}
}
@@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
/// <summary>
/// Class for checking the type of the current Operating System platform.
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using Microsoft.Extensions.DependencyInjection;
using System;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
/// <summary>
/// Defines a factory for creating platform contexts.
@@ -30,4 +30,4 @@ public class PlatformContextFactory : IPlatformContextFactory
{
return _serviceProvider.GetRequiredService<TPlatformContext>() ?? throw new ArgumentException();
}
}
}
@@ -1,10 +1,10 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Common.Enums.FileSystem;
using System;
using System.Runtime.InteropServices;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
/// <summary>
/// Service for managing the platform context.
@@ -34,12 +34,10 @@ public class PlatformContextManager : IPlatformContextManager
{
// set a default context if none is set
if (_currentPlatformContext is null)
{
if (_operatingSystemInfo.IsOSPlatform(OSPlatform.Linux))
if (_operatingSystemInfo.IsOSPlatform(OSPlatform.Linux) || _operatingSystemInfo.IsOSPlatform(OSPlatform.OSX))
SetCurrentPlatform(PlatformType.Unix);
else
SetCurrentPlatform(PlatformType.Windows);
}
return _currentPlatformContext!;
}
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
/// <summary>
/// Platform context for UNIX platforms.
@@ -1,9 +1,10 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
/// <summary>
/// Platform context for Windows platforms.
@@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
/// <summary>
/// Value Object uniquely identifying file system items.
@@ -44,7 +44,7 @@ public sealed class FileSystemPathId : ValueObject
public static ErrorOr<FileSystemPathId> Create(string path)
{
if (string.IsNullOrWhiteSpace(path))
return Errors.FileManagement.InvalidPath;
return Errors.FileSystemManagement.InvalidPath;
return new FileSystemPathId(path);
}
}
@@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
/// <summary>
/// Value object uniquely identifying path segments.
@@ -54,7 +54,7 @@ public class PathSegment : ValueObject
public static ErrorOr<PathSegment> Create(string name, bool isDirectory, bool isDrive)
{
if (string.IsNullOrWhiteSpace(name))
return Errors.FileManagement.NameCannotBeEmpty;
return Errors.FileSystemManagement.NameCannotBeEmpty;
return new PathSegment(name, isDirectory, isDrive);
}
@@ -7,7 +7,7 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
/// <summary>
/// Value Object for the information about a media stream.
@@ -111,11 +111,11 @@ public class StreamInfo : ValueObject
Optional<int> channels)
{
if (streamId is null)
return Errors.FileManagement.StreamIdCannotBeEmpty;
return Errors.FileSystemManagement.StreamIdCannotBeEmpty;
if (codec is null)
return Errors.FileManagement.CodecCannotBeEmpty;
return Errors.FileSystemManagement.CodecCannotBeEmpty;
if (bitrate <= 0)
return Errors.FileManagement.BitrateMustBeAPositiveNumber;
return Errors.FileSystemManagement.BitrateMustBeAPositiveNumber;
return new StreamInfo(streamId, mimeType, bitrate, codec, resolution, frameRate, sampleRate, channels);
}
@@ -1,11 +1,11 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.PhotoLibrary;
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Enums.PhotoLibrary;
using Lumina.Domain.Common.Models.Core;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
/// <summary>
/// Value object for file system thumbnails.
@@ -40,4 +40,4 @@ public class Thumbnail : ValueObject
yield return Type;
yield return Bytes;
}
}
}
@@ -0,0 +1,133 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Common.Enums.MediaLibrary;
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
/// <summary>
/// Aggregate root for a media library.
/// </summary>
[DebuggerDisplay("Id: {Id} Title: {Title}")]
public class Library : AggregateRoot<LibraryId>
{
private readonly List<FileSystemPathId> _contentLocations;
/// <summary>
/// Gets the id of the user owning this media library.
/// </summary>
public UserId UserId { get; private set; }
/// <summary>
/// Gets the type of the media library (e.g., Book, TvShow).
/// </summary>
public LibraryType LibraryType { get; private set; }
/// <summary>
/// Gets the title of the media library.
/// </summary>
public string Title { get; private set; }
/// <summary>
/// Gets the list of file system paths that make up the media library.
/// </summary>
public IReadOnlyCollection<FileSystemPathId> ContentLocations => _contentLocations.AsReadOnly();
/// <summary>
/// Initializes a new instance of the <see cref="Library"/> class.
/// </summary>
/// <param name="id">The unique identifier of the media library.</param>
/// <param name="userId">The unique identifier of the user owning the media library.</param>
/// <param name="title">The title of the media library.</param>
/// <param name="libraryType">The type of the media library (e.g., Book, TvShow).</param>
/// <param name="contentLocations">The list of file system paths that make up the media library.</param>
private Library(
LibraryId id,
UserId userId,
string title,
LibraryType libraryType,
List<FileSystemPathId> contentLocations) : base(id)
{
UserId = userId;
Title = title;
LibraryType = libraryType;
_contentLocations = contentLocations;
}
/// <summary>
/// Creates a new instance of the <see cref="Library"/> class.
/// </summary>
/// <param name="userId">The unique identifier of the user owning the media library.</param>
/// <param name="title">The title of the media library.</param>
/// <param name="libraryType">The type of the media library (e.g., Book, TvShow).</param>
/// <param name="contentLocations">The list of file system paths that make up the media library.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Library"/>, or an error message.
/// </returns>
public static ErrorOr<Library> Create(
Guid userId,
string title,
LibraryType libraryType,
IEnumerable<string> contentLocations)
{
List<FileSystemPathId> tempContentLocations = [];
// go through all the file system paths that make up the media library and create domain objects from them
foreach (string contentLocation in contentLocations)
{
ErrorOr<FileSystemPathId> contentLocationResult = FileSystemPathId.Create(contentLocation);
if (contentLocationResult.IsError)
return contentLocationResult.Errors;
tempContentLocations.Add(contentLocationResult.Value);
}
return new Library(
LibraryId.CreateUnique(),
UserId.Create(userId),
title,
libraryType,
tempContentLocations
);
}
/// <summary>
/// Creates a new instance of the <see cref="Library"/>, with a pre-existing <paramref name="id"/>.
/// </summary>
/// <param name="id">The object representing the id of the media library.</param>
/// <param name="userId">The object representing the id of the user owning the media library.</param>
/// <param name="title">The title of the media library.</param>
/// <param name="libraryType">The type of the media library (e.g., Book, TvShow).</param>
/// <param name="contentLocations">The list of file system paths that make up the media library.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Library"/>, or an error message.
/// </returns>
public static ErrorOr<Library> Create(
LibraryId id,
Guid userId,
string title,
LibraryType libraryType,
IEnumerable<string> contentLocations)
{
List<FileSystemPathId> tempContentLocations = [];
// go through all the file system paths that make up the media library and create domain objects from them
foreach (string contentLocation in contentLocations)
{
ErrorOr<FileSystemPathId> contentLocationResult = FileSystemPathId.Create(contentLocation);
if (contentLocationResult.IsError)
return contentLocationResult.Errors;
tempContentLocations.Add(contentLocationResult.Value);
}
return new Library(
id,
UserId.Create(userId),
title,
libraryType,
tempContentLocations
);
}
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Models.Core;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
/// <summary>
/// Value Object for the Id of a media library.
/// </summary>
[DebuggerDisplay("{Value}")]
public sealed class LibraryId : EntityId<Guid>
{
/// <summary>
/// Initializes a new instance of the <see cref="LibraryId"/> class.
/// </summary>
/// <param name="value">The value representing this object.</param>
private LibraryId(Guid value) : base(value)
{
}
/// <summary>
/// Creates a new instance of the <see cref="LibraryId"/> class.
/// </summary>
/// <returns>The created <see cref="LibraryId"/> instance.</returns>
public static LibraryId CreateUnique()
{
return new LibraryId(Guid.NewGuid());
}
/// <summary>
/// Creates a new instance of the <see cref="LibraryId"/> class, from a pre-existing <paramref name="value"/>.
/// </summary>
/// <param name="value">The value used to create the <see cref="LibraryId"/> instance.</param>
/// <returns>The created <see cref="LibraryId"/> instance.</returns>
public static LibraryId Create(Guid value)
{
return new LibraryId(value);
}
/// <inheritdoc/>
public override IEnumerable<object> GetEqualityComponents()
{
yield return Value;
}
}
@@ -2,13 +2,13 @@
using ErrorOr;
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate;
namespace Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate;
/// <summary>
/// Aggregate Root for a media contributor.
@@ -90,4 +90,4 @@ public class MediaContributor : AggregateRoot<MediaContributorId>
{
return new MediaContributor(id, name, role, dateOfBirth, dateOfDeath);
}
}
}
@@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
/// <summary>
/// Value Object for the name of a person.
@@ -53,4 +53,4 @@ public sealed class MediaContributorName : ValueObject
yield return DisplayName;
yield return LegalName;
}
}
}
@@ -4,7 +4,7 @@ using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
/// <summary>
/// Value Object for the Id of a media contributor.
@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
/// <summary>
/// Value Object for the role of a media contributor.
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate;
/// <summary>
/// Aggregate root for a user aggregate.
/// </summary>
[DebuggerDisplay("{Id}: {Username}")]
public sealed class User : AggregateRoot<UserId>
{
/// <summary>
/// Gets or sets the username of the user.
/// </summary>
public string Username { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="User"/> class.
/// </summary>
/// <param name="id">The unique identifier of the user.</param>
/// <param name="username">The username of the user.</param>
private User(
UserId id,
string username) : base(id)
{
Username = username;
}
/// <summary>
/// Creates a new instance of the <see cref="User"/> class.
/// </summary>
/// <param name="username">The username of the user.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="User"/>, or an error message.
/// </returns>
public static ErrorOr<User> Create(
string username)
{
return new User(
UserId.CreateUnique(),
username);
}
/// <summary>
/// Creates a new instance of the <see cref="User"/>, with a pre-existing <paramref name="id"/>.
/// </summary>
/// <param name="id">The object representing the id of the user.</param>
/// <param name="username">The username of the user.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="User"/>, or an error message.
/// </returns>
public static ErrorOr<User> Create(
UserId id,
string username)
{
return new User(
id,
username);
}
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Models.Core;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
/// <summary>
/// Value Object for the Id of a user.
/// </summary>
[DebuggerDisplay("{Value}")]
public sealed class UserId : EntityId<Guid>
{
/// <summary>
/// Initializes a new instance of the <see cref="UserId"/> class.
/// </summary>
/// <param name="value">The value representing this object.</param>
private UserId(Guid value) : base(value)
{
}
/// <summary>
/// Creates a new instance of the <see cref="UserId"/> class.
/// </summary>
/// <returns>The created <see cref="UserId"/> instance.</returns>
public static UserId CreateUnique()
{
return new UserId(Guid.NewGuid());
}
/// <summary>
/// Creates a new instance of the <see cref="UserId"/> class, from a pre-existing <paramref name="value"/>.
/// </summary>
/// <param name="value">The value used to create the <see cref="UserId"/> instance.</param>
/// <returns>The created <see cref="UserId"/> instance.</returns>
public static UserId Create(Guid value)
{
return new UserId(value);
}
/// <inheritdoc/>
public override IEnumerable<object> GetEqualityComponents()
{
yield return Value;
}
}
@@ -2,13 +2,13 @@
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;
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate;
/// <summary>
/// Entity for a movie.
@@ -85,4 +85,4 @@ public sealed class Movie : Entity<MovieId>
// TODO: enforce invariants
return new Movie(id, metadata, contributors, ratings);
}
}
}
@@ -2,7 +2,7 @@
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.Services;
/// <summary>
/// Interface for the service for managing movie libraries.
@@ -13,4 +13,4 @@ public interface IMovieLibraryService
/// Gets the collection of movies in the library.
/// </summary>
public ICollection<Movie> Movies { get; }
}
}
@@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.Services;
/// <summary>
/// Service for managing movie libraries.
@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
/// <summary>
/// Value Object for the Id of a movie.
@@ -47,4 +47,4 @@ public sealed class MovieId : EntityId<Guid>
{
yield return Value;
}
}
}
@@ -7,7 +7,7 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
/// <summary>
/// Value Object for the video metadata of a media element.
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.Services;
using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.Services;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.Services;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.Services;
/// <summary>
/// Interface for the service for managing video content.
@@ -19,4 +19,4 @@ public interface IVideoLibraryService
/// Gets the service for managing a TV shows library.
/// </summary>
public ITvShowLibraryService TvShowLibraryService { get; }
}
}
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.Services;
using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.Services;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.Services;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.Services;
/// <summary>
/// Service for managing video content.
@@ -1,10 +1,10 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Entities;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.Entities;
/// <summary>
/// Entity for an episode.
@@ -13,4 +13,4 @@ namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Enti
public sealed class Episode : Entity<EpisodeId>
{
}
}
@@ -1,10 +1,10 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Entities;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.Entities;
/// <summary>
/// Entity for a season.
@@ -2,7 +2,7 @@
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.Services;
/// <summary>
/// Interface for the service for managing TV show libraries.
@@ -13,4 +13,4 @@ public interface ITvShowLibraryService
/// Gets the collection of TV shows in the library.
/// </summary>
public ICollection<TvShow> TvShows { get; }
}
}
@@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.Services;
/// <summary>
/// Service for managing TV show libraries.
@@ -1,10 +1,10 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate;
/// <summary>
/// Entity for a TV show.
@@ -13,4 +13,4 @@ namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate;
public sealed class TvShow : Entity<TvShowId>
{
}
}
@@ -4,7 +4,7 @@ using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
/// <summary>
/// Value Object for the Id of an episode.
@@ -45,4 +45,4 @@ public sealed class EpisodeId : EntityId<Guid>
{
yield return Value;
}
}
}
@@ -4,7 +4,7 @@ using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
/// <summary>
/// Value Object for the Id of a season.
Loaded 100 of 853 files, more files were not shown because too many files have changed in this diff. Show more