mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11:11:10 +00:00
Adds File System Domain aggregate
This commit is contained in:
1 parent
4301b0a3ee
commit
dfc7112cb7
51 files changed
+3626
-95
No files matched your search
@@ -0,0 +1,44 @@
|
||||
#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 Microsoft.Extensions.DependencyInjection;
|
||||
using System.IO.Abstractions;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.DependencyInjection;
|
||||
|
||||
/// <summary>
|
||||
/// Contains all services of the Domain layer.
|
||||
/// </summary>
|
||||
public static class DomainLayerServices
|
||||
{
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Registers the services of the Domain layer into the dependency injection container.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection to add the services to.</param>
|
||||
/// <returns>The updated <see cref="IServiceCollection"/>.</returns>
|
||||
public static IServiceCollection AddDomainLayerServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<IDirectoryService, DirectoryService>();
|
||||
services.AddScoped<IFileService, FileService>();
|
||||
services.AddScoped<IFileSystemPermissionsService, FileSystemPermissionsService>();
|
||||
services.AddScoped<IDirectoryProviderService, DirectoryProviderService>();
|
||||
services.AddScoped<IFileProviderService, FileProviderService>();
|
||||
services.AddScoped<IThumbnailService, ThumbnailService>();
|
||||
services.AddScoped<IPathService, PathService>();
|
||||
services.AddScoped<IFileTypeService, FileTypeService>();
|
||||
services.AddScoped<IEnvironmentContext, EnvironmentContext>();
|
||||
services.AddScoped<IPlatformContextFactory, PlatformContextFactory>();
|
||||
services.AddScoped<IUnixPlatformContext, UnixPlatformContext>();
|
||||
services.AddScoped<IWindowsPlatformContext, WindowsPlatformContext>();
|
||||
services.AddScoped<IPlatformContextManager, PlatformContextManager>();
|
||||
services.AddScoped<IUnixPathStrategy, UnixPathStrategy>();
|
||||
services.AddScoped<IWindowsPathStrategy, WindowsPathStrategy>();
|
||||
services.AddSingleton<IFileSystem, FileSystem>();
|
||||
return services;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
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,
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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,
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
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,
|
||||
}
|
||||
@@ -12,11 +12,22 @@ public static partial class Errors
|
||||
public static class FileManagement
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
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 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));
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.Errors;
|
||||
|
||||
/// <summary>
|
||||
/// Domain permission related error types.
|
||||
/// </summary>
|
||||
public static partial class Errors
|
||||
{
|
||||
public static class Permission
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public static Error UnauthorizedAccess => Error.Failure(nameof(UnauthorizedAccess));
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.Errors;
|
||||
|
||||
/// <summary>
|
||||
/// Domain thumbnails related error types.
|
||||
/// </summary>
|
||||
public static partial class Errors
|
||||
{
|
||||
public static class Thumbnails
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public static Error NoThumbnail => Error.Failure(nameof(NoThumbnail));
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user