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,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.
@@ -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 TV show.
@@ -1,22 +1,22 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.BookLibrary;
using Lumina.Domain.Common.Enums.BookLibrary;
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Entities;
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate;
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
/// <summary>
/// Aggregate root for a book.
/// </summary>
[DebuggerDisplay("{Id}: {Title}")]
[DebuggerDisplay("Id: {Id} Title: {Title}")]
public sealed class Book : AggregateRoot<BookId>
{
private readonly List<MediaContributorId> _contributors;
@@ -248,7 +248,8 @@ public sealed class Book : AggregateRoot<BookId>
default,
isbns,
contributors,
ratings);
ratings
);
}
/// <summary>
@@ -320,6 +321,7 @@ public sealed class Book : AggregateRoot<BookId>
updated,
isbns,
contributors,
ratings);
ratings
);
}
}
}
@@ -2,12 +2,12 @@
using ErrorOr;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Entities;
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
/// <summary>
/// Entity for a book series.
@@ -120,4 +120,4 @@ public sealed class BookSeries : Entity<BookSeriesId>
_books.Remove(book);
return Result.Deleted;
}
}
}
@@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services;
/// <summary>
/// Service for managing book libraries.
@@ -14,4 +14,4 @@ public sealed class BookLibraryService : IBookLibraryService
/// Gets the collection of books in the library.
/// </summary>
public ICollection<Book> Books => throw new NotImplementedException();
}
}
@@ -2,7 +2,7 @@
using System.Collections.Generic;
#endregion
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Services;
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services;
/// <summary>
/// Interface for the service for managing book libraries.
@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
/// <summary>
/// Value Object for the Id of a book.
@@ -45,4 +45,4 @@ public sealed class BookId : EntityId<Guid>
{
yield return Value;
}
}
}
@@ -6,13 +6,13 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
/// <summary>
/// Value Object for the Id of a book library.
/// </summary>
[DebuggerDisplay("{Value}")]
public sealed class BookLibraryId : EntityId<Guid>
public sealed class BookLibraryId : EntityId<Guid> // TODO: to be removed
{
/// <summary>
/// Initializes a new instance of the <see cref="BookLibraryId"/> class.
@@ -48,4 +48,4 @@ public sealed class BookLibraryId : EntityId<Guid>
{
yield return Value;
}
}
}
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.BookLibrary;
using Lumina.Domain.Common.Enums.BookLibrary;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Common.ValueObjects.Metadata;
@@ -8,7 +8,7 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
/// <summary>
/// Value Object for the rating of a media element.
@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
/// <summary>
/// Value Object for the Id of a book series.
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.BookLibrary;
using Lumina.Domain.Common.Enums.BookLibrary;
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Models.Core;
using System.Collections.Generic;
@@ -8,7 +8,7 @@ using System.Diagnostics;
using System.Text.RegularExpressions;
#endregion
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
/// <summary>
/// Value Object for the ISBN of a book.
@@ -46,7 +46,7 @@ public sealed class Isbn : ValueObject
/// <param name="value">The value representing this object.</param>
/// <param name="format">The format of the ISBN representing this object.</param>
/// <returns>The created <see cref="Isbn"/> instance.</returns>
public static ErrorOr<Isbn> Create(string value, IsbnFormat format)
public static ErrorOr<Isbn> Create(string? value, IsbnFormat format)
{
// enforce invariants
if (string.IsNullOrWhiteSpace(value))
@@ -7,7 +7,7 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
/// <summary>
/// Value Object for the metadata of a written media element.
@@ -16,12 +16,12 @@ namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggrega
public class WrittenContentMetadata : BaseMetadata
{
/// <summary>
/// Gets the publisher of the written content.
/// Gets the publisher of the written content, if applicable.
/// </summary>
public Optional<string> Publisher { get; }
/// <summary>
/// Gets the number of pages in the written content.
/// Gets the number of pages in the written content, if applicable.
/// </summary>
public Optional<int> PageCount { get; }
@@ -29,15 +29,15 @@ public class WrittenContentMetadata : BaseMetadata
/// Initializes a new instance of the <see cref="WrittenContentMetadata"/> class.
/// </summary>
/// <param name="title">The title of the written content.</param>
/// <param name="originalTitle">The optional original title of the video.</param>
/// <param name="description">The description of the written content.</param>
/// <param name="originalTitle">The optional original title of the written content, if applicable.</param>
/// <param name="description">The description of the written content, if applicable.</param>
/// <param name="releaseInfo">The release information of the written content.</param>
/// <param name="genres">The genres of the written content.</param>
/// <param name="tags">The tags associated with the written content.</param>
/// <param name="language">The language of the written content.</param>
/// <param name="originalLanguage">The optional original language of the video.</param>
/// <param name="publisher">The publisher of the written content.</param>
/// <param name="pageCount">The number of pages in the written content.</param>
/// <param name="language">The language of the written content, if applicable.</param>
/// <param name="originalLanguage">The optional original language of the written content, if applicable.</param>
/// <param name="publisher">The publisher of the written content, if applicable.</param>
/// <param name="pageCount">The number of pages in the written content, if applicable.</param>
private WrittenContentMetadata(
string title,
Optional<string> originalTitle,
@@ -59,15 +59,15 @@ public class WrittenContentMetadata : BaseMetadata
/// Creates a new instance of the <see cref="WrittenContentMetadata"/> class.
/// </summary>
/// <param name="title">The title of the written content.</param>
/// <param name="originalTitle">The optional original title of the video.</param>
/// <param name="description">The description of the written content.</param>
/// <param name="originalTitle">The optional original title of the written content, if applicable.</param>
/// <param name="description">The description of the written content, if applicable.</param>
/// <param name="releaseInfo">The release information of the written content.</param>
/// <param name="genres">The genres of the written content.</param>
/// <param name="tags">The tags associated with the written content.</param>
/// <param name="language">The language of the written content.</param>
/// <param name="originalLanguage">The optional original language of the video.</param>
/// <param name="publisher">The publisher of the written content.</param>
/// <param name="pageCount">The number of pages in the written content.</param>
/// <param name="originalLanguage">The optional original language of the written content, if applicable.</param>
/// <param name="publisher">The publisher of the written content, if applicable.</param>
/// <param name="pageCount">The number of pages in the written content, if applicable.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="WrittenContentMetadata"/>, or an error message.
/// </returns>
@@ -1,8 +1,8 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services;
#endregion
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.Services;
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.Services;
/// <summary>
/// Interface for the service for managing written content.
@@ -13,4 +13,4 @@ public interface IWrittenContentLibraryService
/// Gets the service for managing book libraries.
/// </summary>
public IBookLibraryService BookLibraryService { get; }
}
}
@@ -1,8 +1,8 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services;
#endregion
namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.Services;
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.Services;
/// <summary>
/// Service for managing written content.
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.Aggregates.VideoLibrary.Services;
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.Services;
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.Services;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.Services;
#endregion
namespace Lumina.Domain.Core.Services;
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.Aggregates.VideoLibrary.Services;
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.Services;
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.Services;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.Services;
#endregion
namespace Lumina.Domain.Core.Services;
@@ -8,7 +8,7 @@ namespace Lumina.Domain.Core.Services;
/// <summary>
/// Service for managing media libraries.
/// </summary>
public class MediaLibraryService : IMediaLibraryService
public class MediaLibraryService : IMediaLibraryService // TODO: perhaps a better naming would be IMediaLibraryFacade (same for injected facades here)
{
/// <summary>
/// Gets the service for managing a video library.
@@ -30,4 +30,4 @@ public class MediaLibraryService : IMediaLibraryService
VideoLibraryService = videoLibraryService;
WrittenContentLibraryService = writtenContentLibraryService;
}
}
}