Implements directory browser dialog, part 1: file system treeview

This commit is contained in:
BinaryAlley committed 2024-09-15 13:07:53 +03:00
1 parent 4a53348013
commit 4e4ecbbfca
318 files changed
+6012 -1184

No files matched your search

@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate;
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;
@@ -22,6 +23,7 @@ public static class DomainLayerServices
/// <returns>The updated <see cref="IServiceCollection"/>.</returns>
public static IServiceCollection AddDomainLayerServices(this IServiceCollection services)
{
services.AddScoped<IDriveService, DriveService>();
services.AddScoped<IDirectoryService, DirectoryService>();
services.AddScoped<IFileService, FileService>();
services.AddScoped<IFileSystemPermissionsService, FileSystemPermissionsService>();
@@ -1,27 +0,0 @@
namespace Lumina.Domain.Common.Enums;
/// <summary>
/// Enumeration for the various sources of audio ratings.
/// </summary>
public enum AudioRatingSource
{
/// <summary>
/// Ratings provided by users of the Lumina media library.
/// </summary>
User,
/// <summary>
/// Ratings sourced from MusicBrainz, an open music encyclopedia that collects music metadata.
/// </summary>
MusicBrainz,
/// <summary>
/// Ratings obtained from Discogs, a database and marketplace for music recordings.
/// </summary>
Discogs,
/// <summary>
/// Ratings from Last.fm, a music website that provides music recommendations based on user listening habits.
/// </summary>
LastFm,
}
@@ -1,67 +0,0 @@
namespace Lumina.Domain.Common.Enums;
/// <summary>
/// Enumeration for various book formats.
/// </summary>
public enum BookFormat
{
/// <summary>
/// A book bound with rigid protective covers (typically cardboard covered with cloth, heavy paper, or leather).
/// </summary>
Hardcover,
/// <summary>
/// A book with a flexible paper cover, typically less durable than a hardcover.
/// </summary>
Paperback,
/// <summary>
/// A small, usually non-illustrated, and inexpensive paperback book.
/// </summary>
MassMarketPaperback,
/// <summary>
/// A larger, often higher-quality paperback book, typically used for literary fiction and nonfiction.
/// </summary>
TradePaperback,
/// <summary>
/// A digital version of a book that can be read on electronic devices.
/// </summary>
eBook,
/// <summary>
/// A recorded audio version of a book, either on physical media or as a digital file.
/// </summary>
Audiobook,
/// <summary>
/// A book printed with larger text for easier reading, often used by those with visual impairments.
/// </summary>
LargePrint,
/// <summary>
/// A sturdy book with thick cardboard pages, typically designed for young children.
/// </summary>
BoardBook,
/// <summary>
/// A book bound with a spiral wire or plastic coil, allowing it to lay flat when open.
/// </summary>
SpiralBound,
/// <summary>
/// A reinforced binding designed for frequent use, often used in schools and public libraries.
/// </summary>
LibraryBinding,
/// <summary>
/// A book bound in leather, often used for luxury or collector's editions.
/// </summary>
LeatherBound,
/// <summary>
/// A book with three-dimensional paper engineering, creating pop-up or movable parts.
/// </summary>
PopupBook
}
@@ -1,27 +0,0 @@
namespace Lumina.Domain.Common.Enums;
/// <summary>
/// Enumeration for the various sources of book ratings.
/// </summary>
public enum BookRatingSource
{
/// <summary>
/// Ratings provided by users of the Lumina system.
/// </summary>
User,
/// <summary>
/// Ratings sourced from Goodreads, a social network for book readers that provides book recommendations and reviews.
/// </summary>
Goodreads,
/// <summary>
/// Ratings obtained from Amazon, an e-commerce platform that includes customer reviews and ratings for books.
/// </summary>
Amazon,
/// <summary>
/// Ratings from Google Books, a service that searches the full text of books and magazines that Google has scanned and converted to text.
/// </summary>
GoogleBooks,
}
@@ -1,37 +0,0 @@
namespace Lumina.Domain.Common.Enums;
/// <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,
}
@@ -1,22 +0,0 @@
namespace Lumina.Domain.Common.Enums;
/// <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
}
@@ -1,22 +0,0 @@
namespace Lumina.Domain.Common.Enums;
/// <summary>
/// Enumeration for the types of file system elements.
/// </summary>
public enum FileSystemItemType
{
/// <summary>
/// Represents a drive, such as a hard disk, USB drive, or network drive.
/// </summary>
Drive,
/// <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
}
@@ -1,24 +0,0 @@
namespace Lumina.Domain.Common.Enums;
/// <summary>
/// Enumeration for known image types.
/// </summary>
public enum ImageType
{
None,
BMP,
GIF,
PNG,
TIFF,
JPEG,
JPEG_CANON,
JPEG_UNKNOWN,
PICT,
ICO,
PSD,
JPEG2000,
AVIF,
WEBP,
TGA,
SVG,
}
@@ -1,19 +0,0 @@
namespace Lumina.Domain.Common.Enums;
/// <summary>
/// Enumeration for the different ISBN (International Standard Book Number) formats.
/// </summary>
public enum IsbnFormat
{
/// <summary>
/// The 10-digit ISBN format used for books published before 2007.
/// Example: 0-306-40615-2
/// </summary>
Isbn10,
/// <summary>
/// The 13-digit ISBN format introduced in 2007, now the standard for all new books.
/// Example: 978-0-306-40615-7
/// </summary>
Isbn13
}
@@ -1,17 +0,0 @@
namespace Lumina.Domain.Common.Enums;
/// <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,
}
@@ -1,32 +0,0 @@
namespace Lumina.Domain.Common.Enums;
/// <summary>
/// Enumeration for the various sources of video ratings.
/// </summary>
public enum VideoRatingSource
{
/// <summary>
/// Ratings provided by users of the Lumina media library.
/// </summary>
User,
/// <summary>
/// Ratings sourced from IMDb (Internet Movie Database), an online database of information related to films, TV programs, and video games.
/// </summary>
Imdb,
/// <summary>
/// Ratings obtained from TheTVDB, an open database for television shows, including episode information and user ratings.
/// </summary>
TheTvDb,
/// <summary>
/// Ratings from The Movie Database (TMDb), a community-built movie and TV database.
/// </summary>
TheMovieDb,
/// <summary>
/// Ratings from Rotten Tomatoes, a review-aggregation website for film and television.
/// </summary>
RottenTomatoes,
}
@@ -12,22 +12,23 @@ public static partial class Errors
public static class FileManagement
{
#region ==================================================================== PROPERTIES =================================================================================
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 FileNotFoundError => Error.NotFound(nameof(FileNotFoundError));
public static Error InvalidPathError => Error.Validation(nameof(InvalidPathError));
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 CannotNavigateUpError => Error.Failure(nameof(CannotNavigateUpError));
public static Error NameCannotBeEmptyError => Error.Validation(nameof(NameCannotBeEmptyError));
public static Error FileAlreadyExistsError => Error.Conflict(nameof(FileAlreadyExistsError));
public static Error DirectoryNotFoundError => Error.NotFound(nameof(DirectoryNotFoundError));
public static Error DirectoryAlreadyExistsError => Error.Conflict(nameof(DirectoryAlreadyExistsError));
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));
#endregion
}
}
@@ -1,4 +1,8 @@
namespace Lumina.Domain.Common.Events;
#region ========================================================================= USING =====================================================================================
using System;
#endregion
namespace Lumina.Domain.Common.Events;
/// <summary>
/// Interface defining a domain event.
@@ -6,7 +10,14 @@
public interface IDomainEvent
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets the id of the domain event.
/// </summary>
Guid Id { get; }
/// <summary>
/// Gets the date and time when the domain event occurred.
/// </summary>
DateTime OccurredOn { get; }
#endregion
}
@@ -1,4 +1,8 @@
namespace Lumina.Domain.Common.Models.Core;
#region ========================================================================= USING =====================================================================================
using System;
#endregion
namespace Lumina.Domain.Common.Models.Core;
/// <summary>
/// Base class for all domain Entities.
@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
#endregion
@@ -12,12 +13,15 @@ namespace Lumina.Domain.Common.Models.Core;
public abstract class EntityId<TId> : ValueObject
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets the value representing the entity identifier.
/// </summary>
public TId Value { get; }
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Overload C-tor.
/// Initializes a new instance of the <see cref="EntityId{TId}"/> class.
/// </summary>
/// <param name="value">The value representing this object.</param>
protected EntityId(TId value)
@@ -27,7 +31,7 @@ public abstract class EntityId<TId> : ValueObject
#pragma warning disable CS8618
/// <summary>
/// Default C-tor.
/// Initializes a new instance of the <see cref="EntityId{TId}"/> class.
/// </summary>
protected EntityId()
{
@@ -1,9 +1,14 @@
namespace Lumina.Domain.Common.Models.Core;
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Linq;
#endregion
namespace Lumina.Domain.Common.Models.Core;
/// <summary>
/// Base class for all domain Value Objects.
/// </summary>
/// <typeparam name="TId">The type representing the unique identifier for the Entity. It should be a non-nullable type.</typeparam>
public abstract class ValueObject : IEquatable<ValueObject>
{
#region ===================================================================== METHODS ===================================================================================
+23 -23
View File
@@ -4,11 +4,11 @@ namespace Lumina.Domain.Common.Primitives;
/// Primitive struct for explicitly handling cases when a value might be unknown or not applicable,
/// distinguishing between "not set" and "intentionally empty".
/// </summary>
/// <typeparam name="T">The type of the value represented by this structure.</typeparam>
public readonly struct Optional<T>
/// <typeparam name="TValue">The type of the value represented by this structure.</typeparam>
public readonly struct Optional<TValue>
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly T? _value;
private readonly TValue? _value;
#endregion
#region ==================================================================== PROPERTIES =================================================================================
@@ -20,7 +20,7 @@ public readonly struct Optional<T>
/// <summary>
/// Gets the value represented by this structure.
/// </summary>
public T Value
public TValue Value
{
get
{
@@ -31,11 +31,11 @@ public readonly struct Optional<T>
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="Optional{T}"/> structure.
/// Initializes a new instance of the <see cref="Optional{TValue}"/> structure.
/// </summary>
/// <param name="value">The value represented by this structure.</param>
/// <param name="hasValue"><see langword="true"/> if <paramref name="value"/> is not <see langword="null"/>, <see langword="false"/>otherwise.</param>
private Optional(T? value, bool hasValue)
private Optional(TValue? value, bool hasValue)
{
_value = value;
HasValue = hasValue;
@@ -44,50 +44,50 @@ public readonly struct Optional<T>
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Custom implementation operator for converting <paramref name="value"/> to an <see cref="Optional{T}"/>.
/// Custom implementation operator for converting <paramref name="value"/> to an <see cref="Optional{TValue}"/>.
/// </summary>
/// <param name="value">The value to be converted.</param>
public static implicit operator Optional<T>(T value)
public static implicit operator Optional<TValue>(TValue value)
{
return Some(value);
}
/// <summary>
/// Creates an <see cref="Optional{T}"/> with a value.
/// Creates an <see cref="Optional{TValue}"/> with a value.
/// </summary>
/// <param name="value">The value to wrap in the <see cref="Optional{T}"/>.</param>
/// <returns>An <see cref="Optional{T}"/> containing the specified value.</returns>
public static Optional<T> Some(T value)
/// <param name="value">The value to wrap in the <see cref="Optional{TValue}"/>.</param>
/// <returns>An <see cref="Optional{TValue}"/> containing the specified value.</returns>
public static Optional<TValue> Some(TValue value)
{
return new Optional<T>(value, true);
return new Optional<TValue>(value, true);
}
/// <summary>
/// Creates an <see cref="Optional{T}"/> with no value.
/// Creates an <see cref="Optional{TValue}"/> with no value.
/// </summary>
/// <returns>An empty <see cref="Optional{T}"/>.</returns>
public static Optional<T> None()
/// <returns>An empty <see cref="Optional{TValue}"/>.</returns>
public static Optional<TValue> None()
{
return new(default, false);
}
/// <summary>
/// Creates an <see cref="Optional{T}"/> from a nullable reference type.
/// Creates an <see cref="Optional{TValue}"/> from a nullable reference type.
/// </summary>
/// <param name="value">The nullable value to convert.</param>
/// <returns>An <see cref="Optional{T}"/> representing the nullable value.</returns>
public static Optional<T> FromNullable(T? value)
/// <returns>An <see cref="Optional{TValue}"/> representing the nullable value.</returns>
public static Optional<TValue> FromNullable(TValue? value)
{
return value is null ? None() : Some(value);
}
/// <summary>
/// Creates an <see cref="Optional{T}"/> from a nullable value type.
/// Creates an <see cref="Optional{TValue}"/> from a nullable value type.
/// </summary>
/// <typeparam name="TValue">The underlying value type.</typeparam>
/// <typeparam name="TNullableValue">The underlying value type.</typeparam>
/// <param name="value">The nullable value to convert.</param>
/// <returns>An <see cref="Optional{T}"/> representing the nullable value.</returns>
public static Optional<T> FromNullable<TValue>(TValue? value) where TValue : struct, T
/// <returns>An <see cref="Optional{TValue}"/> representing the nullable value.</returns>
public static Optional<TValue> FromNullable<TNullableValue>(TNullableValue? value) where TNullableValue : struct, TValue
{
return value.HasValue ? Some(value.Value) : None();
}
@@ -1,7 +1,9 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Common.Primitives;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Common.ValueObjects.Metadata;
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Common.Models.Core;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
@@ -36,7 +37,7 @@ public class Genre : ValueObject
/// </summary>
/// <param name="name">The value of the genre.</param>
/// <returns>
/// An <see cref="ErrorOr{T}"/> containing either a successfully created <see cref="Genre"/>, or an error message.
/// 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)
{
@@ -2,6 +2,7 @@
using ErrorOr;
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Common.Primitives;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
@@ -53,7 +54,7 @@ public class LanguageInfo : ValueObject
/// <param name="languageName">The full name of the language in English.</param>
/// <param name="nativeName">The optional native name of the language.</param>
/// <returns>
/// An <see cref="ErrorOr{T}"/> containing either a successfully created <see cref="LanguageInfo"/>, or an error message.
/// 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)
{
@@ -2,6 +2,8 @@
using ErrorOr;
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Common.Primitives;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
@@ -84,7 +86,7 @@ public class ReleaseInfo : ValueObject
/// <param name="releaseCountry">The optional country or region of release.</param>
/// <param name="releaseVersion">The optional release version or edition.</param>
/// <returns>
/// An <see cref="ErrorOr{T}"/> containing either a successfully created <see cref="ReleaseInfo"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="ReleaseInfo"/>, or an error message.
/// </returns>
public static ErrorOr<ReleaseInfo> Create(
Optional<DateOnly> originalReleaseDate,
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Common.Models.Core;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
@@ -36,7 +37,7 @@ public class Tag : ValueObject
/// </summary>
/// <param name="name">The value of the tag.</param>
/// <returns>
/// An <see cref="ErrorOr{T}"/> containing either a successfully created <see cref="Tag"/>, or an error message.
/// 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)
{