mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11:11:10 +00:00
Adds editorconfig and refactors to the established rules
This commit is contained in:
1 parent
712a0f2b27
commit
cd44f11d9e
138 files changed
+1799
-1629
No files matched your search
+38
-38
@@ -64,19 +64,19 @@ public class AudioMetadata : BaseMetadata
|
||||
/// <param name="genres">The genres of the audio.</param>
|
||||
/// <param name="tags">The tags associated with the audio.</param>
|
||||
public AudioMetadata(
|
||||
string title,
|
||||
Optional<string> originalTitle,
|
||||
int durationInSeconds,
|
||||
int sampleRate,
|
||||
int channels,
|
||||
ReleaseInfo releaseInfo,
|
||||
string title,
|
||||
Optional<string> originalTitle,
|
||||
int durationInSeconds,
|
||||
int sampleRate,
|
||||
int channels,
|
||||
ReleaseInfo releaseInfo,
|
||||
Optional<string> description,
|
||||
List<Genre> genres,
|
||||
List<Tag> tags,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> originalLanguage,
|
||||
Optional<int> bitDepth,
|
||||
Optional<string> audioCodec,
|
||||
List<Genre> genres,
|
||||
List<Tag> tags,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> originalLanguage,
|
||||
Optional<int> bitDepth,
|
||||
Optional<string> audioCodec,
|
||||
Optional<int> bitrate)
|
||||
: base(title, originalTitle, description, releaseInfo, genres, tags, language, originalLanguage)
|
||||
{
|
||||
@@ -110,43 +110,43 @@ public class AudioMetadata : BaseMetadata
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="AudioMetadata"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<AudioMetadata> Create(
|
||||
string title,
|
||||
Optional<string> originalTitle,
|
||||
int durationInSeconds,
|
||||
int sampleRate,
|
||||
int channels,
|
||||
ReleaseInfo release,
|
||||
Optional<string>
|
||||
string title,
|
||||
Optional<string> originalTitle,
|
||||
int durationInSeconds,
|
||||
int sampleRate,
|
||||
int channels,
|
||||
ReleaseInfo release,
|
||||
Optional<string>
|
||||
description,
|
||||
List<Genre> genres,
|
||||
List<Tag> tags,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> originalLanguage,
|
||||
Optional<int> bitDepth,
|
||||
Optional<string> audioCodec,
|
||||
List<Genre> genres,
|
||||
List<Tag> tags,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> originalLanguage,
|
||||
Optional<int> bitDepth,
|
||||
Optional<string> audioCodec,
|
||||
Optional<int> bitrate)
|
||||
{
|
||||
return new AudioMetadata(
|
||||
title,
|
||||
originalTitle,
|
||||
durationInSeconds,
|
||||
sampleRate,
|
||||
channels,
|
||||
release,
|
||||
description,
|
||||
genres,
|
||||
title,
|
||||
originalTitle,
|
||||
durationInSeconds,
|
||||
sampleRate,
|
||||
channels,
|
||||
release,
|
||||
description,
|
||||
genres,
|
||||
tags,
|
||||
language,
|
||||
originalLanguage,
|
||||
bitDepth,
|
||||
audioCodec,
|
||||
language,
|
||||
originalLanguage,
|
||||
bitDepth,
|
||||
audioCodec,
|
||||
bitrate);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
foreach (var component in base.GetEqualityComponents())
|
||||
foreach (object component in base.GetEqualityComponents())
|
||||
yield return component;
|
||||
yield return DurationInSeconds;
|
||||
yield return SampleRate;
|
||||
|
||||
+6
-13
@@ -19,7 +19,7 @@ public sealed class Directory : FileSystemItem
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
private readonly List<FileSystemItem> _items = [];
|
||||
#endregion
|
||||
|
||||
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the creation date of the file system item. Can be optional if the information is not available.
|
||||
@@ -34,10 +34,7 @@ public sealed class Directory : FileSystemItem
|
||||
/// <summary>
|
||||
/// Gets the collection of file system items that are children to the current directory entity.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<FileSystemItem> Items
|
||||
{
|
||||
get { return _items.AsReadOnly(); }
|
||||
}
|
||||
public IReadOnlyCollection<FileSystemItem> Items => _items.AsReadOnly();
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
@@ -77,15 +74,13 @@ public sealed class Directory : FileSystemItem
|
||||
ErrorOr<FileSystemPathId> createPathResult = FileSystemPathId.Create(path);
|
||||
if (createPathResult.IsError)
|
||||
return createPathResult.Errors;
|
||||
Directory newDirectory = new Directory(
|
||||
Directory newDirectory = new(
|
||||
createPathResult.Value,
|
||||
name,
|
||||
dateCreated,
|
||||
dateModified);
|
||||
ErrorOr<Updated> setStatusResult = newDirectory.SetStatus(status);
|
||||
if (setStatusResult.IsError)
|
||||
return setStatusResult.Errors;
|
||||
return newDirectory;
|
||||
return setStatusResult.IsError ? (ErrorOr<Directory>)setStatusResult.Errors : (ErrorOr<Directory>)newDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -106,15 +101,13 @@ public sealed class Directory : FileSystemItem
|
||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
Directory newDirectory = new Directory(
|
||||
Directory newDirectory = new(
|
||||
id,
|
||||
name,
|
||||
dateCreated,
|
||||
dateModified);
|
||||
ErrorOr<Updated> setStatusResult = newDirectory.SetStatus(status);
|
||||
if (setStatusResult.IsError)
|
||||
return setStatusResult.Errors;
|
||||
return newDirectory;
|
||||
return setStatusResult.IsError ? (ErrorOr<Directory>)setStatusResult.Errors : (ErrorOr<Directory>)newDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+4
-8
@@ -74,16 +74,14 @@ public sealed class File : FileSystemItem
|
||||
ErrorOr<FileSystemPathId> createPathResult = FileSystemPathId.Create(path);
|
||||
if (createPathResult.IsError)
|
||||
return createPathResult.Errors;
|
||||
File newFile = new File(
|
||||
File newFile = new(
|
||||
createPathResult.Value,
|
||||
name,
|
||||
dateCreated,
|
||||
dateModified,
|
||||
size);
|
||||
ErrorOr<Updated> setStatusResult = newFile.SetStatus(status);
|
||||
if (setStatusResult.IsError)
|
||||
return setStatusResult.Errors;
|
||||
return newFile;
|
||||
return setStatusResult.IsError ? (ErrorOr<File>)setStatusResult.Errors : (ErrorOr<File>)newFile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -107,16 +105,14 @@ public sealed class File : FileSystemItem
|
||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
File newFile = new File(
|
||||
File newFile = new(
|
||||
id,
|
||||
name,
|
||||
dateCreated,
|
||||
dateModified,
|
||||
size);
|
||||
ErrorOr<Updated> setStatusResult = newFile.SetStatus(status);
|
||||
if (setStatusResult.IsError)
|
||||
return setStatusResult.Errors;
|
||||
return newFile;
|
||||
return setStatusResult.IsError ? (ErrorOr<File>)setStatusResult.Errors : (ErrorOr<File>)newFile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+3
-8
@@ -23,10 +23,7 @@ public sealed class UnixRootItem : FileSystemItem
|
||||
/// <summary>
|
||||
/// Gets the collection of file system items that are children to the current file system root entity.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<FileSystemItem> Items
|
||||
{
|
||||
get { return _items.AsReadOnly(); }
|
||||
}
|
||||
public IReadOnlyCollection<FileSystemItem> Items => _items.AsReadOnly();
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
@@ -54,13 +51,11 @@ public sealed class UnixRootItem : FileSystemItem
|
||||
ErrorOr<FileSystemPathId> createPathResult = FileSystemPathId.Create(PATH);
|
||||
if (createPathResult.IsError)
|
||||
return createPathResult.Errors;
|
||||
UnixRootItem newRoot = new UnixRootItem(
|
||||
UnixRootItem newRoot = new(
|
||||
createPathResult.Value,
|
||||
PATH);
|
||||
ErrorOr<Updated> setStatusResult = newRoot.SetStatus(status);
|
||||
if (setStatusResult.IsError)
|
||||
return setStatusResult.Errors;
|
||||
return newRoot;
|
||||
return setStatusResult.IsError ? (ErrorOr<UnixRootItem>)setStatusResult.Errors : (ErrorOr<UnixRootItem>)newRoot;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+6
-13
@@ -22,10 +22,7 @@ public sealed class WindowsRootItem : FileSystemItem
|
||||
/// <summary>
|
||||
/// Gets the collection of file system items that are children to the current file system root entity.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<FileSystemItem> Items
|
||||
{
|
||||
get { return _items.AsReadOnly(); }
|
||||
}
|
||||
public IReadOnlyCollection<FileSystemItem> Items => _items.AsReadOnly();
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
@@ -35,7 +32,7 @@ public sealed class WindowsRootItem : FileSystemItem
|
||||
/// <param name="id">The unique identifier of the root item in the file system path.</param>
|
||||
/// <param name="name">The name of the root item.</param>
|
||||
private WindowsRootItem(FileSystemPathId id, string name) : base(id, name, FileSystemItemType.Root)
|
||||
{
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -58,13 +55,11 @@ public sealed class WindowsRootItem : FileSystemItem
|
||||
ErrorOr<FileSystemPathId> createPathResult = FileSystemPathId.Create(path);
|
||||
if (createPathResult.IsError)
|
||||
return createPathResult.Errors;
|
||||
WindowsRootItem newRoot = new WindowsRootItem(
|
||||
WindowsRootItem newRoot = new(
|
||||
createPathResult.Value,
|
||||
name);
|
||||
ErrorOr<Updated> setStatusResult = newRoot.SetStatus(status);
|
||||
if (setStatusResult.IsError)
|
||||
return setStatusResult.Errors;
|
||||
return newRoot;
|
||||
return setStatusResult.IsError ? (ErrorOr<WindowsRootItem>)setStatusResult.Errors : (ErrorOr<WindowsRootItem>)newRoot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -82,13 +77,11 @@ public sealed class WindowsRootItem : FileSystemItem
|
||||
FileSystemItemStatus status = FileSystemItemStatus.Accessible)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
WindowsRootItem newFile = new WindowsRootItem(
|
||||
WindowsRootItem newFile = new(
|
||||
id,
|
||||
name);
|
||||
ErrorOr<Updated> setStatusResult = newFile.SetStatus(status);
|
||||
if (setStatusResult.IsError)
|
||||
return setStatusResult.Errors;
|
||||
return newFile;
|
||||
return setStatusResult.IsError ? (ErrorOr<WindowsRootItem>)setStatusResult.Errors : (ErrorOr<WindowsRootItem>)newFile;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+11
-11
@@ -44,12 +44,12 @@ internal class DirectoryProviderService : IDirectoryProviderService
|
||||
public ErrorOr<IEnumerable<FileSystemPathId>> GetSubdirectoryPaths(FileSystemPathId path)
|
||||
{
|
||||
// check if the user has access permissions to the provided path
|
||||
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory, false))
|
||||
return Errors.Permission.UnauthorizedAccess;
|
||||
return ErrorOrFactory.From(_fileSystem.Directory.GetDirectories(path.Path)
|
||||
return !_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory, false)
|
||||
? (ErrorOr<IEnumerable<FileSystemPathId>>)Errors.Permission.UnauthorizedAccess
|
||||
: ErrorOrFactory.From(_fileSystem.Directory.GetDirectories(path.Path)
|
||||
.OrderBy(path => path)
|
||||
.Select(path => path.EndsWith(_fileSystem.Path.DirectorySeparatorChar) ? path : path + _fileSystem.Path.DirectorySeparatorChar)
|
||||
.Select(path => FileSystemPathId.Create(path))
|
||||
.Select(FileSystemPathId.Create)
|
||||
.Where(errorOrPathId => !errorOrPathId.IsError)
|
||||
.Select(errorOrPathId => errorOrPathId.Value)
|
||||
.AsEnumerable());
|
||||
@@ -85,9 +85,9 @@ internal class DirectoryProviderService : IDirectoryProviderService
|
||||
public ErrorOr<Optional<DateTime>> GetLastWriteTime(FileSystemPathId path)
|
||||
{
|
||||
// check if the user has access permissions to the provided path
|
||||
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false))
|
||||
return Errors.Permission.UnauthorizedAccess;
|
||||
return Optional<DateTime>.FromNullable(_fileSystem.Directory.GetLastWriteTime(path.Path));
|
||||
return !_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false)
|
||||
? (ErrorOr<Optional<DateTime>>)Errors.Permission.UnauthorizedAccess
|
||||
: (ErrorOr<Optional<DateTime>>)Optional<DateTime>.FromNullable(_fileSystem.Directory.GetLastWriteTime(path.Path));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -98,9 +98,9 @@ internal class DirectoryProviderService : IDirectoryProviderService
|
||||
public ErrorOr<Optional<DateTime>> GetCreationTime(FileSystemPathId path)
|
||||
{
|
||||
// check if the user has access permissions to the provided path
|
||||
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false))
|
||||
return Errors.Permission.UnauthorizedAccess;
|
||||
return Optional<DateTime>.FromNullable(_fileSystem.Directory.GetCreationTime(path.Path));
|
||||
return !_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false)
|
||||
? (ErrorOr<Optional<DateTime>>)Errors.Permission.UnauthorizedAccess
|
||||
: (ErrorOr<Optional<DateTime>>)Optional<DateTime>.FromNullable(_fileSystem.Directory.GetCreationTime(path.Path));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -270,7 +270,7 @@ internal class DirectoryProviderService : IDirectoryProviderService
|
||||
string? newDirectory = _fileSystem.Path.Combine(parentDirectory, name);
|
||||
if (!string.IsNullOrEmpty(newDirectory))
|
||||
{
|
||||
var newDirectoryPathResult = FileSystemPathId.Create(newDirectory);
|
||||
ErrorOr<FileSystemPathId> newDirectoryPathResult = FileSystemPathId.Create(newDirectory);
|
||||
if (newDirectoryPathResult.IsError)
|
||||
return newDirectoryPathResult.Errors;
|
||||
if (!_fileSystemPermissionsService.CanAccessPath(parendDirectoryResult.Value, FileAccessMode.Write, false))
|
||||
|
||||
+16
-28
@@ -45,9 +45,7 @@ public class DirectoryService : IDirectoryService
|
||||
public ErrorOr<IEnumerable<Directory>> GetSubdirectories(string path)
|
||||
{
|
||||
ErrorOr<FileSystemPathId> fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
if (fileSystemPathIdResult.IsError)
|
||||
return fileSystemPathIdResult.Errors;
|
||||
return GetSubdirectories(fileSystemPathIdResult.Value);
|
||||
return fileSystemPathIdResult.IsError ? (ErrorOr<IEnumerable<Directory>>)fileSystemPathIdResult.Errors : GetSubdirectories(fileSystemPathIdResult.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -84,9 +82,9 @@ public class DirectoryService : IDirectoryService
|
||||
if (dirNameResult.IsError || dateModifiedResult.IsError || dateCreatedResult.IsError)
|
||||
{
|
||||
ErrorOr<Directory> errorDirResult = Directory.Create(subPath, !dirNameResult.IsError ? dirNameResult.Value : null!,
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsError ? dateModifiedResult.Value : Optional<DateTime>.None());
|
||||
if(errorDirResult.IsError)
|
||||
if (errorDirResult.IsError)
|
||||
return errorDirResult.Errors;
|
||||
ErrorOr<Updated> setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||
if (setStatusResult.IsError)
|
||||
@@ -113,9 +111,7 @@ public class DirectoryService : IDirectoryService
|
||||
public ErrorOr<Directory> CreateDirectory(string path, string name)
|
||||
{
|
||||
ErrorOr<FileSystemPathId> fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
if (fileSystemPathIdResult.IsError)
|
||||
return fileSystemPathIdResult.Errors;
|
||||
return CreateDirectory(fileSystemPathIdResult.Value, name);
|
||||
return fileSystemPathIdResult.IsError ? (ErrorOr<Directory>)fileSystemPathIdResult.Errors : CreateDirectory(fileSystemPathIdResult.Value, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -148,14 +144,12 @@ public class DirectoryService : IDirectoryService
|
||||
if (dirNameResult.IsError || dateModifiedResult.IsError || dateCreatedResult.IsError)
|
||||
{
|
||||
ErrorOr<Directory> errorDirResult = Directory.Create(newDirectoryPathResult.Value, !dirNameResult.IsError ? dirNameResult.Value : null!,
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsError ? dateModifiedResult.Value : Optional<DateTime>.None());
|
||||
if (errorDirResult.IsError)
|
||||
return errorDirResult.Errors;
|
||||
ErrorOr<Updated> setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||
if (setStatusResult.IsError)
|
||||
return setStatusResult.Errors;
|
||||
return errorDirResult;
|
||||
return setStatusResult.IsError ? (ErrorOr<Directory>)setStatusResult.Errors : errorDirResult;
|
||||
}
|
||||
else
|
||||
return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value);
|
||||
@@ -180,9 +174,9 @@ public class DirectoryService : IDirectoryService
|
||||
if (fileSystemSourcePathIdResult.IsError)
|
||||
return fileSystemSourcePathIdResult.Errors;
|
||||
ErrorOr<FileSystemPathId> fileSystemDestinationPathIdResult = FileSystemPathId.Create(destinationPath);
|
||||
if (fileSystemDestinationPathIdResult.IsError)
|
||||
return fileSystemDestinationPathIdResult.Errors;
|
||||
return CopyDirectory(fileSystemSourcePathIdResult.Value, fileSystemDestinationPathIdResult.Value, overrideExisting ?? false);
|
||||
return fileSystemDestinationPathIdResult.IsError
|
||||
? (ErrorOr<Directory>)fileSystemDestinationPathIdResult.Errors
|
||||
: CopyDirectory(fileSystemSourcePathIdResult.Value, fileSystemDestinationPathIdResult.Value, overrideExisting ?? false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -226,9 +220,9 @@ public class DirectoryService : IDirectoryService
|
||||
if (fileSystemSourcePathIdResult.IsError)
|
||||
return fileSystemSourcePathIdResult.Errors;
|
||||
ErrorOr<FileSystemPathId> fileSystemDestinationPathIdResult = FileSystemPathId.Create(destinationPath);
|
||||
if (fileSystemDestinationPathIdResult.IsError)
|
||||
return fileSystemDestinationPathIdResult.Errors;
|
||||
return MoveDirectory(fileSystemSourcePathIdResult.Value, fileSystemDestinationPathIdResult.Value, overrideExisting ?? false);
|
||||
return fileSystemDestinationPathIdResult.IsError
|
||||
? (ErrorOr<Directory>)fileSystemDestinationPathIdResult.Errors
|
||||
: MoveDirectory(fileSystemSourcePathIdResult.Value, fileSystemDestinationPathIdResult.Value, overrideExisting ?? false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -263,9 +257,7 @@ public class DirectoryService : IDirectoryService
|
||||
public ErrorOr<Directory> RenameDirectory(string path, string name)
|
||||
{
|
||||
ErrorOr<FileSystemPathId> fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
if (fileSystemPathIdResult.IsError)
|
||||
return fileSystemPathIdResult.Errors;
|
||||
return RenameDirectory(fileSystemPathIdResult.Value, name);
|
||||
return fileSystemPathIdResult.IsError ? (ErrorOr<Directory>)fileSystemPathIdResult.Errors : RenameDirectory(fileSystemPathIdResult.Value, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -298,14 +290,12 @@ public class DirectoryService : IDirectoryService
|
||||
if (dirNameResult.IsError || dateModifiedResult.IsError || dateCreatedResult.IsError)
|
||||
{
|
||||
ErrorOr<Directory> errorDirResult = Directory.Create(newDirectoryPathResult.Value, !dirNameResult.IsError ? dirNameResult.Value : null!,
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsError ? dateModifiedResult.Value : Optional<DateTime>.None());
|
||||
if (errorDirResult.IsError)
|
||||
return errorDirResult.Errors;
|
||||
ErrorOr<Updated> setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||
if (setStatusResult.IsError)
|
||||
return setStatusResult.Errors;
|
||||
return errorDirResult;
|
||||
return setStatusResult.IsError ? (ErrorOr<Directory>)setStatusResult.Errors : errorDirResult;
|
||||
}
|
||||
else
|
||||
return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value);
|
||||
@@ -320,9 +310,7 @@ public class DirectoryService : IDirectoryService
|
||||
public ErrorOr<Deleted> DeleteDirectory(string path)
|
||||
{
|
||||
ErrorOr<FileSystemPathId> fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
if (fileSystemPathIdResult.IsError)
|
||||
return fileSystemPathIdResult.Errors;
|
||||
return DeleteDirectory(fileSystemPathIdResult.Value);
|
||||
return fileSystemPathIdResult.IsError ? (ErrorOr<Deleted>)fileSystemPathIdResult.Errors : DeleteDirectory(fileSystemPathIdResult.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+3
-5
@@ -41,10 +41,8 @@ public class DriveService : IDriveService
|
||||
{
|
||||
if (_platformContext.Platform == PlatformType.Unix)
|
||||
{
|
||||
var unixRootResult = UnixRootItem.Create(FileSystemItemStatus.Accessible);
|
||||
if (unixRootResult.IsError)
|
||||
return unixRootResult.Errors;
|
||||
return new List<FileSystemItem>() { unixRootResult.Value };
|
||||
ErrorOr<UnixRootItem> unixRootResult = UnixRootItem.Create(FileSystemItemStatus.Accessible);
|
||||
return unixRootResult.IsError ? (ErrorOr<IEnumerable<FileSystemItem>>)unixRootResult.Errors : (ErrorOr<IEnumerable<FileSystemItem>>)new List<FileSystemItem>() { unixRootResult.Value };
|
||||
}
|
||||
else
|
||||
return ErrorOrFactory.From(_fileSystem.DriveInfo.GetDrives()
|
||||
@@ -53,7 +51,7 @@ public class DriveService : IDriveService
|
||||
.Select(driveInfo =>
|
||||
{
|
||||
ErrorOr<FileSystemItem> root;
|
||||
var windowsRootResult = WindowsRootItem.Create(driveInfo.Name, driveInfo.Name);
|
||||
ErrorOr<WindowsRootItem> windowsRootResult = WindowsRootItem.Create(driveInfo.Name, driveInfo.Name);
|
||||
if (windowsRootResult.IsError)
|
||||
return windowsRootResult.Errors;
|
||||
else
|
||||
|
||||
+17
-17
@@ -44,11 +44,11 @@ internal class FileProviderService : IFileProviderService
|
||||
public ErrorOr<IEnumerable<FileSystemPathId>> GetFilePaths(FileSystemPathId path)
|
||||
{
|
||||
// check if the user has access permissions to the provided path
|
||||
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory))
|
||||
return Errors.Permission.UnauthorizedAccess;
|
||||
return ErrorOrFactory.From(_fileSystem.Directory.GetFiles(path.Path)
|
||||
return !_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory)
|
||||
? (ErrorOr<IEnumerable<FileSystemPathId>>)Errors.Permission.UnauthorizedAccess
|
||||
: ErrorOrFactory.From(_fileSystem.Directory.GetFiles(path.Path)
|
||||
.OrderBy(p => p)
|
||||
.Select(p => FileSystemPathId.Create(p))
|
||||
.Select(FileSystemPathId.Create)
|
||||
.Where(errorOrPathId => !errorOrPathId.IsError)
|
||||
.Select(errorOrPathId => errorOrPathId.Value)
|
||||
.AsEnumerable());
|
||||
@@ -82,9 +82,9 @@ internal class FileProviderService : IFileProviderService
|
||||
public ErrorOr<byte[]> GetFileAsync(FileSystemPathId path)
|
||||
{
|
||||
// check if the user has access permissions to the provided path
|
||||
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadContents))
|
||||
return Errors.Permission.UnauthorizedAccess;
|
||||
return System.IO.File.ReadAllBytes(path.Path);
|
||||
return !_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadContents)
|
||||
? (ErrorOr<byte[]>)Errors.Permission.UnauthorizedAccess
|
||||
: (ErrorOr<byte[]>)System.IO.File.ReadAllBytes(path.Path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -95,9 +95,9 @@ internal class FileProviderService : IFileProviderService
|
||||
public ErrorOr<Optional<DateTime>> GetLastWriteTime(FileSystemPathId path)
|
||||
{
|
||||
// check if the user has access permissions to the provided path
|
||||
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties))
|
||||
return Errors.Permission.UnauthorizedAccess;
|
||||
return Optional<DateTime>.FromNullable(_fileSystem.File.GetLastWriteTime(path.Path));
|
||||
return !_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties)
|
||||
? (ErrorOr<Optional<DateTime>>)Errors.Permission.UnauthorizedAccess
|
||||
: (ErrorOr<Optional<DateTime>>)Optional<DateTime>.FromNullable(_fileSystem.File.GetLastWriteTime(path.Path));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -108,9 +108,9 @@ internal class FileProviderService : IFileProviderService
|
||||
public ErrorOr<Optional<DateTime>> GetCreationTime(FileSystemPathId path)
|
||||
{
|
||||
// check if the user has access permissions to the provided path
|
||||
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties))
|
||||
return Errors.Permission.UnauthorizedAccess;
|
||||
return Optional<DateTime>.FromNullable(_fileSystem.File.GetCreationTime(path.Path));
|
||||
return !_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties)
|
||||
? (ErrorOr<Optional<DateTime>>)Errors.Permission.UnauthorizedAccess
|
||||
: (ErrorOr<Optional<DateTime>>)Optional<DateTime>.FromNullable(_fileSystem.File.GetCreationTime(path.Path));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -121,9 +121,9 @@ internal class FileProviderService : IFileProviderService
|
||||
public ErrorOr<long?> GetSize(FileSystemPathId path)
|
||||
{
|
||||
// check if the user has access permissions to the provided path
|
||||
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties))
|
||||
return Errors.Permission.UnauthorizedAccess;
|
||||
return _fileSystem.FileInfo.New(path.Path)?.Length ?? 0;
|
||||
return !_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties)
|
||||
? (ErrorOr<long?>)Errors.Permission.UnauthorizedAccess
|
||||
: (ErrorOr<long?>)(_fileSystem.FileInfo.New(path.Path)?.Length ?? 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -233,7 +233,7 @@ internal class FileProviderService : IFileProviderService
|
||||
string? newFile = _fileSystem.Path.Combine(parendDirectoryResult.Value.Path, name);
|
||||
if (!string.IsNullOrEmpty(newFile))
|
||||
{
|
||||
var newFilePathResult = FileSystemPathId.Create(newFile);
|
||||
ErrorOr<FileSystemPathId> newFilePathResult = FileSystemPathId.Create(newFile);
|
||||
if (newFilePathResult.IsError)
|
||||
return newFilePathResult.Errors;
|
||||
// check if the user has access permissions to the provided path
|
||||
|
||||
+29
-41
@@ -44,10 +44,8 @@ public class FileService : IFileService
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a collection of files or an error.</returns>
|
||||
public ErrorOr<IEnumerable<File>> GetFiles(string path)
|
||||
{
|
||||
var fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
if (fileSystemPathIdResult.IsError)
|
||||
return fileSystemPathIdResult.Errors;
|
||||
return GetFiles(fileSystemPathIdResult.Value);
|
||||
ErrorOr<FileSystemPathId> fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
return fileSystemPathIdResult.IsError ? (ErrorOr<IEnumerable<File>>)fileSystemPathIdResult.Errors : GetFiles(fileSystemPathIdResult.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,7 +69,7 @@ public class FileService : IFileService
|
||||
ErrorOr<IEnumerable<FileSystemPathId>> filePathsResult = _environmentContext.FileProviderService.GetFilePaths(path);
|
||||
if (filePathsResult.IsError)
|
||||
return filePathsResult.Errors;
|
||||
List<File> result = new();
|
||||
List<File> result = [];
|
||||
IEnumerable<FileSystemPathId> filePaths = filePathsResult.Value;
|
||||
foreach (FileSystemPathId filePath in filePaths)
|
||||
{
|
||||
@@ -85,7 +83,7 @@ public class FileService : IFileService
|
||||
if (fileNameResult.IsError || dateModifiedResult.IsError || dateCreatedResult.IsError)
|
||||
{
|
||||
ErrorOr<File> errorFileResult = File.Create(filePath, !fileNameResult.IsError ? fileNameResult.Value : null!,
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsError ? dateModifiedResult.Value : Optional<DateTime>.None(), size);
|
||||
if (errorFileResult.IsError)
|
||||
return errorFileResult.Errors;
|
||||
@@ -96,7 +94,7 @@ public class FileService : IFileService
|
||||
}
|
||||
else
|
||||
{
|
||||
var fileResult = File.Create(filePath, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size);
|
||||
ErrorOr<File> fileResult = File.Create(filePath, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size);
|
||||
if (fileResult.IsError)
|
||||
return fileResult.Errors;
|
||||
result.Add(fileResult.Value);
|
||||
@@ -117,13 +115,13 @@ public class FileService : IFileService
|
||||
// make sure the paths are in the expected format
|
||||
if (!destinationDirectoryPath.EndsWith(_platformContext.PathStrategy.PathSeparator))
|
||||
destinationDirectoryPath += _platformContext.PathStrategy.PathSeparator;
|
||||
var fileSystemSourcePathIdResult = FileSystemPathId.Create(sourceFilePath);
|
||||
ErrorOr<FileSystemPathId> fileSystemSourcePathIdResult = FileSystemPathId.Create(sourceFilePath);
|
||||
if (fileSystemSourcePathIdResult.IsError)
|
||||
return fileSystemSourcePathIdResult.Errors;
|
||||
var fileSystemDestinationPathIdResult = FileSystemPathId.Create(destinationDirectoryPath);
|
||||
if (fileSystemDestinationPathIdResult.IsError)
|
||||
return fileSystemDestinationPathIdResult.Errors;
|
||||
return CopyFile(fileSystemSourcePathIdResult.Value, fileSystemDestinationPathIdResult.Value, overrideExisting ?? false);
|
||||
ErrorOr<FileSystemPathId> fileSystemDestinationPathIdResult = FileSystemPathId.Create(destinationDirectoryPath);
|
||||
return fileSystemDestinationPathIdResult.IsError
|
||||
? (ErrorOr<File>)fileSystemDestinationPathIdResult.Errors
|
||||
: CopyFile(fileSystemSourcePathIdResult.Value, fileSystemDestinationPathIdResult.Value, overrideExisting ?? false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -135,7 +133,7 @@ public class FileService : IFileService
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either the copied file, or an error.</returns>
|
||||
public ErrorOr<File> CopyFile(FileSystemPathId sourceFilePath, FileSystemPathId destinationDirectoryPath, bool overrideExisting)
|
||||
{
|
||||
var fileExists = _environmentContext.FileProviderService.FileExists(sourceFilePath);
|
||||
ErrorOr<bool> fileExists = _environmentContext.FileProviderService.FileExists(sourceFilePath);
|
||||
if (fileExists.IsError)
|
||||
return fileExists.Errors;
|
||||
else if (fileExists.Value == false)
|
||||
@@ -155,14 +153,12 @@ public class FileService : IFileService
|
||||
if (fileNameResult.IsError || dateModifiedResult.IsError || dateCreatedResult.IsError)
|
||||
{
|
||||
ErrorOr<File> errorFileResult = File.Create(copyFileResult.Value, !fileNameResult.IsError ? fileNameResult.Value : null!,
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsError ? dateModifiedResult.Value : Optional<DateTime>.None(), size);
|
||||
if (errorFileResult.IsError)
|
||||
return errorFileResult.Errors;
|
||||
ErrorOr<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||
if (setStatusResult.IsError)
|
||||
return setStatusResult.Errors;
|
||||
return errorFileResult;
|
||||
return setStatusResult.IsError ? (ErrorOr<File>)setStatusResult.Errors : errorFileResult;
|
||||
}
|
||||
else
|
||||
return File.Create(copyFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size);
|
||||
@@ -181,13 +177,13 @@ public class FileService : IFileService
|
||||
// make sure the paths are in the expected format
|
||||
if (!destinationDirectoryPath.EndsWith(_platformContext.PathStrategy.PathSeparator))
|
||||
destinationDirectoryPath += _platformContext.PathStrategy.PathSeparator;
|
||||
var fileSystemSourcePathIdResult = FileSystemPathId.Create(sourceFilePath);
|
||||
ErrorOr<FileSystemPathId> fileSystemSourcePathIdResult = FileSystemPathId.Create(sourceFilePath);
|
||||
if (fileSystemSourcePathIdResult.IsError)
|
||||
return fileSystemSourcePathIdResult.Errors;
|
||||
var fileSystemDestinationPathIdResult = FileSystemPathId.Create(destinationDirectoryPath);
|
||||
if (fileSystemDestinationPathIdResult.IsError)
|
||||
return fileSystemDestinationPathIdResult.Errors;
|
||||
return MoveFile(fileSystemSourcePathIdResult.Value, fileSystemDestinationPathIdResult.Value, overrideExisting ?? false);
|
||||
ErrorOr<FileSystemPathId> fileSystemDestinationPathIdResult = FileSystemPathId.Create(destinationDirectoryPath);
|
||||
return fileSystemDestinationPathIdResult.IsError
|
||||
? (ErrorOr<File>)fileSystemDestinationPathIdResult.Errors
|
||||
: MoveFile(fileSystemSourcePathIdResult.Value, fileSystemDestinationPathIdResult.Value, overrideExisting ?? false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -199,7 +195,7 @@ public class FileService : IFileService
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either the moved file, or an error.</returns>
|
||||
public ErrorOr<File> MoveFile(FileSystemPathId sourceFilePath, FileSystemPathId destinationDirectoryPath, bool overrideExisting)
|
||||
{
|
||||
var fileExists = _environmentContext.FileProviderService.FileExists(sourceFilePath);
|
||||
ErrorOr<bool> fileExists = _environmentContext.FileProviderService.FileExists(sourceFilePath);
|
||||
if (fileExists.IsError)
|
||||
return fileExists.Errors;
|
||||
else if (fileExists.Value == false)
|
||||
@@ -219,14 +215,12 @@ public class FileService : IFileService
|
||||
if (fileNameResult.IsError || dateModifiedResult.IsError || dateCreatedResult.IsError)
|
||||
{
|
||||
ErrorOr<File> errorFileResult = File.Create(moveFileResult.Value, !fileNameResult.IsError ? fileNameResult.Value : null!,
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsError ? dateModifiedResult.Value : Optional<DateTime>.None(), size);
|
||||
if (errorFileResult.IsError)
|
||||
return errorFileResult.Errors;
|
||||
ErrorOr<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||
if (setStatusResult.IsError)
|
||||
return setStatusResult.Errors;
|
||||
return errorFileResult;
|
||||
return setStatusResult.IsError ? (ErrorOr<File>)setStatusResult.Errors : errorFileResult;
|
||||
}
|
||||
else
|
||||
return File.Create(moveFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size);
|
||||
@@ -241,10 +235,8 @@ public class FileService : IFileService
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either the renamed file, or an error.</returns>
|
||||
public ErrorOr<File> RenameFile(string path, string name)
|
||||
{
|
||||
var fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
if (fileSystemPathIdResult.IsError)
|
||||
return fileSystemPathIdResult.Errors;
|
||||
return RenameFile(fileSystemPathIdResult.Value, name);
|
||||
ErrorOr<FileSystemPathId> fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
return fileSystemPathIdResult.IsError ? (ErrorOr<File>)fileSystemPathIdResult.Errors : RenameFile(fileSystemPathIdResult.Value, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -256,10 +248,10 @@ public class FileService : IFileService
|
||||
public ErrorOr<File> RenameFile(FileSystemPathId path, string name)
|
||||
{
|
||||
// first, check if the directory about to be created does not already exist
|
||||
var combinedPath = _platformContext.PathStrategy.CombinePath(path, name);
|
||||
ErrorOr<FileSystemPathId> combinedPath = _platformContext.PathStrategy.CombinePath(path, name);
|
||||
if (combinedPath.IsError)
|
||||
return combinedPath.Errors;
|
||||
var fileExists = _environmentContext.FileProviderService.FileExists(combinedPath.Value);
|
||||
ErrorOr<bool> fileExists = _environmentContext.FileProviderService.FileExists(combinedPath.Value);
|
||||
if (fileExists.IsError)
|
||||
return fileExists.Errors;
|
||||
else if (fileExists.Value == true)
|
||||
@@ -279,14 +271,12 @@ public class FileService : IFileService
|
||||
if (fileNameResult.IsError || dateModifiedResult.IsError || dateCreatedResult.IsError)
|
||||
{
|
||||
ErrorOr<File> errorFileResult = File.Create(newFilePathResult.Value, !fileNameResult.IsError ? fileNameResult.Value : null!,
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateCreatedResult.IsError ? dateCreatedResult.Value : Optional<DateTime>.None(),
|
||||
!dateModifiedResult.IsError ? dateModifiedResult.Value : Optional<DateTime>.None(), size);
|
||||
if (errorFileResult.IsError)
|
||||
return errorFileResult.Errors;
|
||||
ErrorOr<Updated> setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible);
|
||||
if (setStatusResult.IsError)
|
||||
return setStatusResult.Errors;
|
||||
return errorFileResult;
|
||||
return setStatusResult.IsError ? (ErrorOr<File>)setStatusResult.Errors : errorFileResult;
|
||||
}
|
||||
else
|
||||
return File.Create(newFilePathResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size);
|
||||
@@ -300,10 +290,8 @@ public class FileService : IFileService
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either the result of deleting a file, or an error.</returns>
|
||||
public ErrorOr<Deleted> DeleteFile(string path)
|
||||
{
|
||||
var fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
if (fileSystemPathIdResult.IsError)
|
||||
return fileSystemPathIdResult.Errors;
|
||||
return DeleteFile(fileSystemPathIdResult.Value);
|
||||
ErrorOr<FileSystemPathId> fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
return fileSystemPathIdResult.IsError ? (ErrorOr<Deleted>)fileSystemPathIdResult.Errors : DeleteFile(fileSystemPathIdResult.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+4
-4
@@ -29,7 +29,7 @@ internal class FileSystemPermissionsService : IFileSystemPermissionsService
|
||||
/// <param name="platformContextManager">Injected facade service for platform contextual services.</param>
|
||||
public FileSystemPermissionsService(IPlatformContextManager platformContextManager)
|
||||
{
|
||||
_platformContextManager = platformContextManager;
|
||||
_platformContextManager = platformContextManager;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -85,7 +85,7 @@ internal class FileSystemPermissionsService : IFileSystemPermissionsService
|
||||
modes = AccessModes.F_OK; // check existence, not an exact match but the closest
|
||||
break;
|
||||
case FileAccessMode.Delete:
|
||||
if (fileInfo.FileType == FileTypes.Directory)
|
||||
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
|
||||
{
|
||||
@@ -147,7 +147,7 @@ internal class FileSystemPermissionsService : IFileSystemPermissionsService
|
||||
_ = fileSystemInfo.CreationTime; // trigger potential access denial
|
||||
break;
|
||||
case FileAccessMode.ReadContents:
|
||||
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
using (FileStream stream = new(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
stream.Close();
|
||||
break;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ internal class FileSystemPermissionsService : IFileSystemPermissionsService
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
+6
-9
@@ -60,7 +60,7 @@ public class FileTypeService : IFileTypeService
|
||||
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadContents))
|
||||
return Errors.Permission.UnauthorizedAccess;
|
||||
Memory<byte> buffer = new byte[BUFFER_SIZE];
|
||||
using var stream = _fileSystem.FileStream.New(path.Path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
|
||||
using FileSystemStream stream = _fileSystem.FileStream.New(path.Path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
|
||||
// check if the file's length is less than the buffer size
|
||||
if (stream.Length < BUFFER_SIZE)
|
||||
return ImageType.None;
|
||||
@@ -73,12 +73,9 @@ public class FileTypeService : IFileTypeService
|
||||
return type;
|
||||
// no known image header types were found, check other methods
|
||||
string content = Encoding.UTF8.GetString(buffer.ToArray());
|
||||
if (IsSvg(content, path.Path))
|
||||
return ImageType.SVG;
|
||||
else if (IsTga(buffer.ToArray()))
|
||||
return ImageType.TGA;
|
||||
else
|
||||
return ImageType.None;
|
||||
return IsSvg(content, path.Path)
|
||||
? (ErrorOr<ImageType>)ImageType.SVG
|
||||
: IsTga(buffer.ToArray()) ? (ErrorOr<ImageType>)ImageType.TGA : (ErrorOr<ImageType>)ImageType.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -96,7 +93,7 @@ public class FileTypeService : IFileTypeService
|
||||
if (initialContent.StartsWith("<?xml", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Read more content from the file
|
||||
using var stream = _fileSystem.FileStream.New(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
|
||||
using FileSystemStream stream = _fileSystem.FileStream.New(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
|
||||
byte[] svgBuffer = new byte[1000];
|
||||
stream.Read(svgBuffer, 0, 1000);
|
||||
string extendedContent = Encoding.UTF8.GetString(svgBuffer);
|
||||
@@ -116,7 +113,7 @@ public class FileTypeService : IFileTypeService
|
||||
if (buffer.Length < 18)
|
||||
return false;
|
||||
byte imageType = buffer[2];
|
||||
return imageType == 1 || imageType == 2 || imageType == 10;
|
||||
return imageType is 1 or 2 or 10;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.S
|
||||
/// <summary>
|
||||
/// Interface for the service for handling thumbnails.
|
||||
/// </summary>
|
||||
public interface IThumbnailService
|
||||
public interface IThumbnailService
|
||||
{
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
|
||||
+7
-22
@@ -20,10 +20,7 @@ public class PathService : IPathService
|
||||
/// <summary>
|
||||
/// Gets the character used to separate path segments.
|
||||
/// </summary>
|
||||
public char PathSeparator
|
||||
{
|
||||
get { return _platformContext.PathStrategy.PathSeparator; }
|
||||
}
|
||||
public char PathSeparator => _platformContext.PathStrategy.PathSeparator;
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
@@ -46,9 +43,7 @@ public class PathService : IPathService
|
||||
public bool IsValidPath(string path)
|
||||
{
|
||||
ErrorOr<FileSystemPathId> newPathResult = FileSystemPathId.Create(path);
|
||||
if (newPathResult.IsError)
|
||||
return false;
|
||||
return _platformContext.PathStrategy.IsValidPath(newPathResult.Value);
|
||||
return !newPathResult.IsError && _platformContext.PathStrategy.IsValidPath(newPathResult.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -59,9 +54,7 @@ public class PathService : IPathService
|
||||
public bool Exists(string path)
|
||||
{
|
||||
ErrorOr<FileSystemPathId> newPathResult = FileSystemPathId.Create(path);
|
||||
if (newPathResult.IsError)
|
||||
return false;
|
||||
return _platformContext.PathStrategy.Exists(newPathResult.Value);
|
||||
return !newPathResult.IsError && _platformContext.PathStrategy.Exists(newPathResult.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -76,9 +69,7 @@ public class PathService : IPathService
|
||||
if (newPathResult.IsError)
|
||||
return newPathResult.Errors;
|
||||
ErrorOr<FileSystemPathId> combinedPathResult = _platformContext.PathStrategy.CombinePath(newPathResult.Value, name);
|
||||
if (combinedPathResult.IsError)
|
||||
return combinedPathResult.Errors;
|
||||
return combinedPathResult.Value.Path;
|
||||
return combinedPathResult.IsError ? (ErrorOr<string>)combinedPathResult.Errors : (ErrorOr<string>)combinedPathResult.Value.Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -89,9 +80,7 @@ public class PathService : IPathService
|
||||
public ErrorOr<IEnumerable<PathSegment>> ParsePath(string path)
|
||||
{
|
||||
ErrorOr<FileSystemPathId> newPathResult = FileSystemPathId.Create(path);
|
||||
if (newPathResult.IsError)
|
||||
return newPathResult.Errors;
|
||||
return _platformContext.PathStrategy.ParsePath(newPathResult.Value);
|
||||
return newPathResult.IsError ? (ErrorOr<IEnumerable<PathSegment>>)newPathResult.Errors : _platformContext.PathStrategy.ParsePath(newPathResult.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -102,9 +91,7 @@ public class PathService : IPathService
|
||||
public ErrorOr<IEnumerable<PathSegment>> GoUpOneLevel(string path)
|
||||
{
|
||||
ErrorOr<FileSystemPathId> newPathResult = FileSystemPathId.Create(path);
|
||||
if (newPathResult.IsError)
|
||||
return newPathResult.Errors;
|
||||
return _platformContext.PathStrategy.GoUpOneLevel(newPathResult.Value);
|
||||
return newPathResult.IsError ? (ErrorOr<IEnumerable<PathSegment>>)newPathResult.Errors : _platformContext.PathStrategy.GoUpOneLevel(newPathResult.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -124,9 +111,7 @@ public class PathService : IPathService
|
||||
public ErrorOr<PathSegment> GetPathRoot(string path)
|
||||
{
|
||||
ErrorOr<FileSystemPathId> newPathResult = FileSystemPathId.Create(path);
|
||||
if (newPathResult.IsError)
|
||||
return newPathResult.Errors;
|
||||
return _platformContext.PathStrategy.GetPathRoot(newPathResult.Value);
|
||||
return newPathResult.IsError ? (ErrorOr<PathSegment>)newPathResult.Errors : _platformContext.PathStrategy.GetPathRoot(newPathResult.Value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+21
-20
@@ -44,10 +44,10 @@ public class ThumbnailService : IThumbnailService
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a collection of bytes representing the thumbnail of the file at the specified path or an error.</returns>
|
||||
public async Task<ErrorOr<Thumbnail>> GetThumbnailAsync(string path, int quality)
|
||||
{
|
||||
var fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
if (fileSystemPathIdResult.IsError)
|
||||
return fileSystemPathIdResult.Errors;
|
||||
return await GetThumbnailAsync(fileSystemPathIdResult.Value, quality);
|
||||
ErrorOr<FileSystemPathId> fileSystemPathIdResult = FileSystemPathId.Create(path);
|
||||
return fileSystemPathIdResult.IsError
|
||||
? (ErrorOr<Thumbnail>)fileSystemPathIdResult.Errors
|
||||
: await GetThumbnailAsync(fileSystemPathIdResult.Value, quality);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -59,21 +59,21 @@ public class ThumbnailService : IThumbnailService
|
||||
public async Task<ErrorOr<Thumbnail>> GetThumbnailAsync(FileSystemPathId path, int quality)
|
||||
{
|
||||
// first, get the type of the image file
|
||||
var imageTypeResult = await _environmentContext.FileTypeService.GetImageTypeAsync(path);
|
||||
ErrorOr<ImageType> imageTypeResult = await _environmentContext.FileTypeService.GetImageTypeAsync(path);
|
||||
if (imageTypeResult.IsError)
|
||||
return imageTypeResult.Errors;
|
||||
if (imageTypeResult.Value != ImageType.None)
|
||||
{
|
||||
// then, get its bytes
|
||||
var resultFileContents = _environmentContext.FileProviderService.GetFileAsync(path);
|
||||
ErrorOr<byte[]> resultFileContents = _environmentContext.FileProviderService.GetFileAsync(path);
|
||||
if (resultFileContents.IsError)
|
||||
return resultFileContents.Errors;
|
||||
byte[] fileContents = resultFileContents.Value;
|
||||
// finally, resize or adjust quality based on image type
|
||||
byte[]? adjustedImage = null;
|
||||
if (imageTypeResult.Value == ImageType.JPEG || imageTypeResult.Value == ImageType.JPEG_CANON || imageTypeResult.Value == ImageType.JPEG2000
|
||||
|| imageTypeResult.Value == ImageType.JPEG_UNKNOWN || imageTypeResult.Value == ImageType.PNG || imageTypeResult.Value == ImageType.BMP
|
||||
|| imageTypeResult.Value == ImageType.WEBP || imageTypeResult.Value == ImageType.GIF || imageTypeResult.Value == ImageType.TIFF || imageTypeResult.Value == ImageType.TGA)
|
||||
if (imageTypeResult.Value is ImageType.JPEG or ImageType.JPEG_CANON or ImageType.JPEG2000
|
||||
or ImageType.JPEG_UNKNOWN or ImageType.PNG or ImageType.BMP
|
||||
or ImageType.WEBP or ImageType.GIF or ImageType.TIFF or ImageType.TGA)
|
||||
adjustedImage = await AdjustImageResolutionAsync(fileContents, imageTypeResult.Value, quality);
|
||||
return new Thumbnail(imageTypeResult.Value, adjustedImage ?? fileContents);
|
||||
}
|
||||
@@ -90,8 +90,8 @@ public class ThumbnailService : IThumbnailService
|
||||
/// <returns>A byte array representing the processed image.</returns>
|
||||
private static async Task<byte[]> AdjustImageQualityAsync(byte[] imageBytes, ImageType imageType, int quality)
|
||||
{
|
||||
using var inputMemoryStream = new MemoryStream(imageBytes);
|
||||
using var outputMemoryStream = new MemoryStream();
|
||||
using MemoryStream inputMemoryStream = new(imageBytes);
|
||||
using MemoryStream outputMemoryStream = new();
|
||||
switch (imageType)
|
||||
{
|
||||
case ImageType.JPEG:
|
||||
@@ -99,22 +99,23 @@ public class ThumbnailService : IThumbnailService
|
||||
case ImageType.JPEG_CANON:
|
||||
case ImageType.JPEG_UNKNOWN:
|
||||
{
|
||||
using var image = await Image.LoadAsync(inputMemoryStream);
|
||||
using Image image = await Image.LoadAsync(inputMemoryStream);
|
||||
await image.SaveAsync(outputMemoryStream, new JpegEncoder() { Quality = quality });
|
||||
break;
|
||||
}
|
||||
case ImageType.PNG:
|
||||
{
|
||||
using var image = await Image.LoadAsync(inputMemoryStream);
|
||||
using Image image = await Image.LoadAsync(inputMemoryStream);
|
||||
// PNG is lossless; quality adjustments don't apply in the same way - we can adjust compression
|
||||
int compressionLevel = MapRange(quality, 1, 100, 1, 9);
|
||||
var encoder = new PngEncoder { CompressionLevel = (PngCompressionLevel)compressionLevel };
|
||||
PngEncoder encoder = new()
|
||||
{ CompressionLevel = (PngCompressionLevel)compressionLevel };
|
||||
await image.SaveAsync(outputMemoryStream, encoder);
|
||||
break;
|
||||
}
|
||||
case ImageType.BMP:
|
||||
{
|
||||
using var image = await Image.LoadAsync(inputMemoryStream);
|
||||
using Image image = await Image.LoadAsync(inputMemoryStream);
|
||||
await image.SaveAsync(outputMemoryStream, new PngEncoder()); // convert BMP to PNG for compression
|
||||
break;
|
||||
}
|
||||
@@ -133,8 +134,8 @@ public class ThumbnailService : IThumbnailService
|
||||
/// <returns>The bytes of the adjusted image.</returns>
|
||||
private static async Task<byte[]> AdjustImageResolutionAsync(byte[] imageBytes, ImageType imageType, int quality)
|
||||
{
|
||||
using var inputMemoryStream = new MemoryStream(imageBytes);
|
||||
using var outputMemoryStream = new MemoryStream();
|
||||
using MemoryStream inputMemoryStream = new(imageBytes);
|
||||
using MemoryStream outputMemoryStream = new();
|
||||
Image image = await Image.LoadAsync(inputMemoryStream);
|
||||
double ratio = quality / 100.0;
|
||||
int newWidth = (int)(image.Width * ratio);
|
||||
@@ -142,7 +143,7 @@ public class ThumbnailService : IThumbnailService
|
||||
// ensure new dimensions are not zero
|
||||
newWidth = Math.Max(1, newWidth);
|
||||
newHeight = Math.Max(1, newHeight);
|
||||
var options = new ResizeOptions
|
||||
ResizeOptions options = new()
|
||||
{
|
||||
Size = new Size(newWidth, newHeight),
|
||||
Mode = ResizeMode.Max
|
||||
@@ -166,7 +167,7 @@ public class ThumbnailService : IThumbnailService
|
||||
break;
|
||||
default:
|
||||
return imageBytes; // for unsupported formats, just return the original bytes
|
||||
}
|
||||
}
|
||||
return outputMemoryStream.ToArray();
|
||||
}
|
||||
|
||||
@@ -183,7 +184,7 @@ public class ThumbnailService : IThumbnailService
|
||||
/// </returns>
|
||||
private static int MapRange(int value, int fromSource, int toSource, int fromTarget, int toTarget)
|
||||
{
|
||||
return (value - fromSource) * (toTarget - fromTarget) / (toSource - fromSource) + fromTarget;
|
||||
return ((value - fromSource) * (toTarget - fromTarget) / (toSource - fromSource)) + fromTarget;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Environment;
|
||||
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Environment;
|
||||
|
||||
+8
-13
@@ -21,10 +21,7 @@ public class UnixPathStrategy : IUnixPathStrategy
|
||||
#endregion
|
||||
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public char PathSeparator
|
||||
{
|
||||
get { return '/'; }
|
||||
}
|
||||
public char PathSeparator => '/';
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
@@ -47,13 +44,13 @@ public class UnixPathStrategy : IUnixPathStrategy
|
||||
public bool IsValidPath(FileSystemPathId path)
|
||||
{
|
||||
// check for invalid path characters
|
||||
var invalidChars = GetInvalidPathCharsForPlatform();
|
||||
char[] invalidChars = GetInvalidPathCharsForPlatform();
|
||||
if (path.Path.IndexOfAny(invalidChars) >= 0)
|
||||
return false;
|
||||
// check for relative paths
|
||||
if (path.Path.StartsWith("./") || path.Path.StartsWith("../"))
|
||||
return false;
|
||||
var pathPattern = @"^\/([\w\-\.\~!$&'()*+,;=:@ ]+(\/[\w\-\.\~!$&'()*+,;=:@ ]+)*)?\/?$";
|
||||
string pathPattern = @"^\/([\w\-\.\~!$&'()*+,;=:@ ]+(\/[\w\-\.\~!$&'()*+,;=:@ ]+)*)?\/?$";
|
||||
return Regex.IsMatch(path.Path, pathPattern);
|
||||
}
|
||||
|
||||
@@ -124,15 +121,13 @@ public class UnixPathStrategy : IUnixPathStrategy
|
||||
if (tempPath.EndsWith('/'))
|
||||
tempPath = tempPath.TrimEnd(PathSeparator);
|
||||
// find the last occurrence of a slash
|
||||
var lastIndex = tempPath.LastIndexOf(PathSeparator);
|
||||
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 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)
|
||||
return newPathResult.Errors;
|
||||
return ParsePath(newPathResult.Value);
|
||||
return newPathResult.IsError ? (ErrorOr<IEnumerable<PathSegment>>)newPathResult.Errors : ParsePath(newPathResult.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -155,9 +150,9 @@ public class UnixPathStrategy : IUnixPathStrategy
|
||||
return Errors.FileManagement.InvalidPath;
|
||||
|
||||
// On Unix-like systems, the root is always "/"
|
||||
if (path.Path.StartsWith(PathSeparator))
|
||||
return new PathSegment(PathSeparator.ToString(), isDirectory: false, isDrive: true);
|
||||
return Errors.FileManagement.InvalidPath;
|
||||
return path.Path.StartsWith(PathSeparator)
|
||||
? (ErrorOr<PathSegment>)new PathSegment(PathSeparator.ToString(), isDirectory: false, isDrive: true)
|
||||
: (ErrorOr<PathSegment>)Errors.FileManagement.InvalidPath;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+17
-22
@@ -1,12 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using ErrorOr;
|
||||
using System.Collections.Generic;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using System.Text.RegularExpressions;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
|
||||
@@ -21,10 +21,7 @@ public class WindowsPathStrategy : IWindowsPathStrategy
|
||||
#endregion
|
||||
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
public char PathSeparator
|
||||
{
|
||||
get { return '\\'; }
|
||||
}
|
||||
public char PathSeparator => '\\';
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
@@ -47,12 +44,12 @@ public class WindowsPathStrategy : IWindowsPathStrategy
|
||||
public bool IsValidPath(FileSystemPathId path)
|
||||
{
|
||||
// check for invalid path characters
|
||||
var invalidChars = GetInvalidPathCharsForPlatform();
|
||||
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)
|
||||
var pathPattern = @"^[a-zA-Z]:\\(?:[a-zA-Z0-9\s()._-]+\\)*[a-zA-Z0-9\s()._-]*\\?$";
|
||||
string pathPattern = @"^[a-zA-Z]:\\(?:[a-zA-Z0-9\s()._-]+\\)*[a-zA-Z0-9\s()._-]*\\?$";
|
||||
return Regex.IsMatch(path.Path, pathPattern);
|
||||
}
|
||||
|
||||
@@ -92,18 +89,18 @@ public class WindowsPathStrategy : IWindowsPathStrategy
|
||||
public ErrorOr<IEnumerable<PathSegment>> ParsePath(FileSystemPathId path)
|
||||
{
|
||||
// Windows paths usually start with a drive letter and colon, e.g., "C:"
|
||||
if (!path.Path.Contains(':') || !path.Path.Contains(PathSeparator) || !char.IsLetter(path.Path[0]) || path.Path[1] != ':' || path.Path[2] != PathSeparator)
|
||||
return Errors.FileManagement.InvalidPath;
|
||||
return ErrorOrFactory.From(GetPathSegments());
|
||||
return !path.Path.Contains(':') || !path.Path.Contains(PathSeparator) || !char.IsLetter(path.Path[0]) || path.Path[1] != ':' || path.Path[2] != PathSeparator
|
||||
? (ErrorOr<IEnumerable<PathSegment>>)Errors.FileManagement.InvalidPath
|
||||
: ErrorOrFactory.From(GetPathSegments());
|
||||
IEnumerable<PathSegment> GetPathSegments()
|
||||
{
|
||||
// the drive segment
|
||||
yield return new PathSegment(path.Path[..2], isDirectory: false, isDrive: true);
|
||||
// extract the other segments
|
||||
var segments = path.Path[3..].Split(new[] { PathSeparator }, StringSplitOptions.RemoveEmptyEntries);
|
||||
for (var i = 0; i < segments.Length; i++)
|
||||
string[] segments = path.Path[3..].Split(new[] { PathSeparator }, StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < segments.Length; i++)
|
||||
{
|
||||
var segment = segments[i];
|
||||
string segment = segments[i];
|
||||
bool isDirectory;
|
||||
if (segment.Contains('.'))
|
||||
isDirectory = i != segments.Length - 1 || path.Path.EndsWith(PathSeparator); // check if it's the last segment or if the next segment also contains a path delimiter
|
||||
@@ -132,15 +129,13 @@ public class WindowsPathStrategy : IWindowsPathStrategy
|
||||
if (tempPath.EndsWith('\\'))
|
||||
tempPath = tempPath.TrimEnd(PathSeparator);
|
||||
// find the last occurrence of a slash
|
||||
var lastIndex = tempPath.LastIndexOf(PathSeparator);
|
||||
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;
|
||||
// if we are at the drive root level after trimming, return drive root, otherwise, return the path up to the last slash
|
||||
ErrorOr<FileSystemPathId> newPathResult = FileSystemPathId.Create(lastIndex == 2 && tempPath[1] == ':' ? tempPath[..3] : tempPath[..lastIndex]);
|
||||
if (newPathResult.IsError)
|
||||
return newPathResult.Errors;
|
||||
return ParsePath(newPathResult.Value);
|
||||
return newPathResult.IsError ? (ErrorOr<IEnumerable<PathSegment>>)newPathResult.Errors : ParsePath(newPathResult.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -172,11 +167,11 @@ public class WindowsPathStrategy : IWindowsPathStrategy
|
||||
// check for UNC paths (e.g., "\\server\share")
|
||||
if (path.Path.StartsWith('\\'))
|
||||
{
|
||||
var parseResult = ParsePath(path);
|
||||
ErrorOr<IEnumerable<PathSegment>> parseResult = ParsePath(path);
|
||||
if (parseResult.IsError)
|
||||
return parseResult.Errors;
|
||||
|
||||
var segments = parseResult.Value.ToList();
|
||||
List<PathSegment> segments = parseResult.Value.ToList();
|
||||
if (segments.Count >= 2)
|
||||
{
|
||||
string root = $@"\\{segments[0].Name}\{segments[1].Name}\";
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public class WindowsPlatformContext : IWindowsPlatformContext
|
||||
/// Gets the platform type, which is Windows for this context.
|
||||
/// </summary>
|
||||
public PlatformType Platform { get; } = PlatformType.Windows;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path strategy for Windows platforms.
|
||||
/// </summary>
|
||||
|
||||
+1
-3
@@ -48,9 +48,7 @@ public sealed class FileSystemPathId : ValueObject
|
||||
/// </returns>
|
||||
public static ErrorOr<FileSystemPathId> Create(string path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
return Errors.FileManagement.InvalidPath;
|
||||
return new FileSystemPathId(path);
|
||||
return string.IsNullOrWhiteSpace(path) ? (ErrorOr<FileSystemPathId>)Errors.FileManagement.InvalidPath : (ErrorOr<FileSystemPathId>)new FileSystemPathId(path);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+26
-26
@@ -20,37 +20,37 @@ public class StreamInfo : ValueObject
|
||||
/// Gets the id of the stream.
|
||||
/// </summary>
|
||||
public string StreamId { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MimeType of the stream.
|
||||
/// </summary>
|
||||
public string MimeType { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the bitrate of the stream.
|
||||
/// </summary>
|
||||
public int Bitrate { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the codec of the stream.
|
||||
/// </summary>
|
||||
public string Codec { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional resolution of the stream.
|
||||
/// </summary>
|
||||
public Optional<string> Resolution { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional frame rate of the stream.
|
||||
/// </summary>
|
||||
public Optional<float> FrameRate { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional sample rate of the stream.
|
||||
/// </summary>
|
||||
public Optional<int> SampleRate { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional channels of the stream.
|
||||
/// </summary>
|
||||
@@ -70,13 +70,13 @@ public class StreamInfo : ValueObject
|
||||
/// <param name="sampleRate">The sample rate of the stream (for audio).</param>
|
||||
/// <param name="channels">The number of channels (for audio).</param>
|
||||
private StreamInfo(
|
||||
string streamId,
|
||||
string mimeType,
|
||||
int bitrate,
|
||||
string streamId,
|
||||
string mimeType,
|
||||
int bitrate,
|
||||
string codec,
|
||||
Optional<string> resolution,
|
||||
Optional<string> resolution,
|
||||
Optional<float> frameRate,
|
||||
Optional<int> sampleRate,
|
||||
Optional<int> sampleRate,
|
||||
Optional<int> channels)
|
||||
{
|
||||
StreamId = streamId;
|
||||
@@ -106,24 +106,24 @@ public class StreamInfo : ValueObject
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="StreamInfo"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<StreamInfo> Create(
|
||||
string streamId,
|
||||
string mimeType,
|
||||
int bitrate,
|
||||
string streamId,
|
||||
string mimeType,
|
||||
int bitrate,
|
||||
string codec,
|
||||
Optional<string> resolution,
|
||||
Optional<float> frameRate,
|
||||
Optional<int> sampleRate,
|
||||
Optional<string> resolution,
|
||||
Optional<float> frameRate,
|
||||
Optional<int> sampleRate,
|
||||
Optional<int> channels)
|
||||
{
|
||||
if (streamId is null)
|
||||
return Errors.FileManagement.StreamIdCannotBeEmpty;
|
||||
if (codec is null)
|
||||
return Errors.FileManagement.CodecCannotBeEmpty;
|
||||
if (bitrate <= 0)
|
||||
return Errors.FileManagement.BitrateMustBeAPositiveNumber;
|
||||
return new StreamInfo(streamId, mimeType, bitrate, codec, resolution, frameRate, sampleRate, channels);
|
||||
return streamId is null
|
||||
? (ErrorOr<StreamInfo>)Errors.FileManagement.StreamIdCannotBeEmpty
|
||||
: codec is null
|
||||
? (ErrorOr<StreamInfo>)Errors.FileManagement.CodecCannotBeEmpty
|
||||
: bitrate <= 0
|
||||
? (ErrorOr<StreamInfo>)Errors.FileManagement.BitrateMustBeAPositiveNumber
|
||||
: (ErrorOr<StreamInfo>)new StreamInfo(streamId, mimeType, bitrate, codec, resolution, frameRate, sampleRate, channels);
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
|
||||
+8
-8
@@ -53,10 +53,10 @@ public class MediaContributor : AggregateRoot<MediaContributorId>
|
||||
/// <param name="dateOfBirth">The optional date of birth of the contributor.</param>
|
||||
/// <param name="dateOfBirth">The optional date of death of the contributor.</param>
|
||||
private MediaContributor(
|
||||
MediaContributorId id,
|
||||
MediaContributorName name,
|
||||
MediaContributorRole role,
|
||||
Optional<DateOnly> dateOfBirth,
|
||||
MediaContributorId id,
|
||||
MediaContributorName name,
|
||||
MediaContributorRole role,
|
||||
Optional<DateOnly> dateOfBirth,
|
||||
Optional<DateOnly> dateOfDeath)
|
||||
{
|
||||
Id = id;
|
||||
@@ -87,10 +87,10 @@ public class MediaContributor : AggregateRoot<MediaContributorId>
|
||||
/// <param name="name">The name of the contributor.</param>
|
||||
/// <returns>The created <see cref="MediaContributor"/> instance.</returns>
|
||||
public static ErrorOr<MediaContributor> Create(
|
||||
MediaContributorId id,
|
||||
MediaContributorName name,
|
||||
MediaContributorRole role,
|
||||
Optional<DateOnly> dateOfBirth,
|
||||
MediaContributorId id,
|
||||
MediaContributorName name,
|
||||
MediaContributorRole role,
|
||||
Optional<DateOnly> dateOfBirth,
|
||||
Optional<DateOnly> dateOfDeath)
|
||||
{
|
||||
return new MediaContributor(id, name, role, dateOfBirth, dateOfDeath);
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public sealed class MediaContributorName : ValueObject
|
||||
public static ErrorOr<MediaContributorName> Create(string displayName, Optional<string> legalName)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new MediaContributorName(displayName, legalName);
|
||||
return new MediaContributorName(displayName, legalName);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ public sealed class MediaContributorId : EntityId<Guid>
|
||||
public static MediaContributorId CreateUnique()
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new MediaContributorId(Guid.NewGuid());
|
||||
return new MediaContributorId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -40,7 +40,7 @@ public sealed class MediaContributorId : EntityId<Guid>
|
||||
public static MediaContributorId Create(Guid value)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new MediaContributorId(value);
|
||||
return new MediaContributorId(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -30,18 +30,12 @@ public sealed class Movie : Entity<MovieId>
|
||||
/// <summary>
|
||||
/// Gets the list of ratings for this movie.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<Rating> Ratings
|
||||
{
|
||||
get { return _ratings.AsReadOnly(); }
|
||||
}
|
||||
public IReadOnlyCollection<Rating> Ratings => _ratings.AsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of media contributors (actors, directors, etc) starring in this movie.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<MediaContributorId> Contributors
|
||||
{
|
||||
get { return _contributors.AsReadOnly(); }
|
||||
}
|
||||
public IReadOnlyCollection<MediaContributorId> Contributors => _contributors.AsReadOnly();
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
@@ -66,7 +60,7 @@ public sealed class Movie : Entity<MovieId>
|
||||
/// </summary>
|
||||
private Movie() // only needed during reflection
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
#pragma warning restore CS8618
|
||||
#endregion
|
||||
|
||||
+1
-4
@@ -14,9 +14,6 @@ public sealed class MovieLibraryService : IMovieLibraryService
|
||||
/// <summary>
|
||||
/// Gets the collection of movies in the library.
|
||||
/// </summary>
|
||||
public ICollection<Movie> Movies
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
public ICollection<Movie> Movies => throw new NotImplementedException();
|
||||
#endregion
|
||||
}
|
||||
+3
-3
@@ -12,7 +12,7 @@ namespace Lumina.Domain.Core.Aggregates.VideoLibrary.MovieLibraryAggregate.Value
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Value}")]
|
||||
public sealed class MovieId : EntityId<Guid>
|
||||
{
|
||||
{
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MovieId"/> class.
|
||||
@@ -31,7 +31,7 @@ public sealed class MovieId : EntityId<Guid>
|
||||
public static MovieId CreateUnique()
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new MovieId(Guid.NewGuid());
|
||||
return new MovieId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +42,7 @@ public sealed class MovieId : EntityId<Guid>
|
||||
public static MovieId Create(Guid value)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new MovieId(value);
|
||||
return new MovieId(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
+21
-21
@@ -60,18 +60,18 @@ public class VideoMetadata : BaseMetadata
|
||||
/// <param name="genres">The genres of the video.</param>
|
||||
/// <param name="tags">The tags associated with the video.</param>
|
||||
private VideoMetadata(
|
||||
string title,
|
||||
Optional<string> originalTitle,
|
||||
int durationInSeconds,
|
||||
string resolution,
|
||||
string title,
|
||||
Optional<string> originalTitle,
|
||||
int durationInSeconds,
|
||||
string resolution,
|
||||
Optional<string> description,
|
||||
ReleaseInfo releaseInfo,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> originalLanguage,
|
||||
Optional<float> frameRate,
|
||||
Optional<string> videoCodec,
|
||||
ReleaseInfo releaseInfo,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> originalLanguage,
|
||||
Optional<float> frameRate,
|
||||
Optional<string> videoCodec,
|
||||
Optional<string> audioCodec,
|
||||
List<Genre> genres,
|
||||
List<Genre> genres,
|
||||
List<Tag> tags)
|
||||
: base(title, originalTitle, description, releaseInfo, genres, tags, language, originalLanguage)
|
||||
{
|
||||
@@ -104,18 +104,18 @@ public class VideoMetadata : BaseMetadata
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="VideoMetadata"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<VideoMetadata> Create(
|
||||
string title,
|
||||
Optional<string> originalTitle,
|
||||
int durationInSeconds,
|
||||
string resolution,
|
||||
string title,
|
||||
Optional<string> originalTitle,
|
||||
int durationInSeconds,
|
||||
string resolution,
|
||||
Optional<string> description,
|
||||
ReleaseInfo releaseInfo,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> originalLanguage,
|
||||
Optional<float> frameRate,
|
||||
Optional<string> videoCodec,
|
||||
ReleaseInfo releaseInfo,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> originalLanguage,
|
||||
Optional<float> frameRate,
|
||||
Optional<string> videoCodec,
|
||||
Optional<string> audioCodec,
|
||||
List<Genre> genres,
|
||||
List<Genre> genres,
|
||||
List<Tag> tags)
|
||||
{
|
||||
return new VideoMetadata(title, originalTitle, durationInSeconds, resolution, description, releaseInfo,
|
||||
@@ -125,7 +125,7 @@ public class VideoMetadata : BaseMetadata
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
foreach (var component in base.GetEqualityComponents())
|
||||
foreach (object component in base.GetEqualityComponents())
|
||||
yield return component;
|
||||
yield return DurationInSeconds;
|
||||
yield return Resolution;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Entities;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.Entities;
|
||||
|
||||
+1
-4
@@ -14,9 +14,6 @@ public class TvShowLibraryService : ITvShowLibraryService
|
||||
/// <summary>
|
||||
/// Gets the collection of TV shows in the library.
|
||||
/// </summary>
|
||||
public ICollection<TvShow> TvShows
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
public ICollection<TvShow> TvShows => throw new NotImplementedException();
|
||||
#endregion
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate.ValueObjects;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.Aggregates.VideoLibrary.TvShowLibraryAggregate;
|
||||
|
||||
+3
-12
@@ -99,26 +99,17 @@ public sealed class Book : AggregateRoot<BookId>
|
||||
/// <summary>
|
||||
/// Gets the list of ISBN (International Standard Book Number) of the book.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<Isbn> ISBNs
|
||||
{
|
||||
get { return _isbns.AsReadOnly(); }
|
||||
}
|
||||
public IReadOnlyCollection<Isbn> ISBNs => _isbns.AsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of media contributors (actors, directors, etc) starring in this book.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<MediaContributorId> Contributors
|
||||
{
|
||||
get { return _contributors.AsReadOnly(); }
|
||||
}
|
||||
public IReadOnlyCollection<MediaContributorId> Contributors => _contributors.AsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of ratings for this book.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<BookRating> Ratings
|
||||
{
|
||||
get { return _ratings.AsReadOnly(); }
|
||||
}
|
||||
public IReadOnlyCollection<BookRating> Ratings => _ratings.AsReadOnly();
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
|
||||
+4
-7
@@ -33,10 +33,7 @@ public sealed class BookSeries : Entity<BookSeriesId>
|
||||
/// <summary>
|
||||
/// Gets the collection of books in the series.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<Book> Books
|
||||
{
|
||||
get { return _books.AsReadOnly(); }
|
||||
}
|
||||
public IReadOnlyCollection<Book> Books => _books.AsReadOnly();
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
@@ -69,9 +66,9 @@ public sealed class BookSeries : Entity<BookSeriesId>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="BookSeries"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<BookSeries> Create(
|
||||
BookSeriesId id,
|
||||
WrittenContentMetadata metadata,
|
||||
bool isComplete,
|
||||
BookSeriesId id,
|
||||
WrittenContentMetadata metadata,
|
||||
bool isComplete,
|
||||
List<Book> books)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
|
||||
+1
-4
@@ -14,9 +14,6 @@ public sealed class BookLibraryService : IBookLibraryService
|
||||
/// <summary>
|
||||
/// Gets the collection of books in the library.
|
||||
/// </summary>
|
||||
public ICollection<Book> Books
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
public ICollection<Book> Books => throw new NotImplementedException();
|
||||
#endregion
|
||||
}
|
||||
+1
-1
@@ -14,7 +14,7 @@ public interface IBookLibraryService
|
||||
/// Gets the collection of books in the library.
|
||||
/// </summary>
|
||||
ICollection<Book> Books { get; }
|
||||
|
||||
|
||||
// ICollection<BookSeries> Series { get; }
|
||||
#endregion
|
||||
|
||||
|
||||
+3
-5
@@ -51,11 +51,9 @@ public class BookRating : Rating
|
||||
/// </returns>
|
||||
public static ErrorOr<BookRating> Create(decimal value, decimal maxValue, Optional<BookRatingSource> source, Optional<int> voteCount)
|
||||
{
|
||||
if (maxValue < 0 || value < 0)
|
||||
return Errors.Metadata.RatingValueMustBePositive;
|
||||
if (value > maxValue)
|
||||
return Errors.Metadata.RatingValueCannotBeGreaterThanMaxValue;
|
||||
return new BookRating(value, maxValue, source, voteCount);
|
||||
return maxValue < 0 || value < 0
|
||||
? (ErrorOr<BookRating>)Errors.Metadata.RatingValueMustBePositive
|
||||
: value > maxValue ? (ErrorOr<BookRating>)Errors.Metadata.RatingValueCannotBeGreaterThanMaxValue : (ErrorOr<BookRating>)new BookRating(value, maxValue, source, voteCount);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
+19
-19
@@ -48,7 +48,7 @@ public class WrittenContentMetadata : BaseMetadata
|
||||
ReleaseInfo releaseInfo,
|
||||
List<Genre> genres,
|
||||
List<Tag> tags,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> language,
|
||||
Optional<LanguageInfo> originalLanguage,
|
||||
Optional<string> publisher,
|
||||
Optional<int> pageCount)
|
||||
@@ -88,23 +88,23 @@ public class WrittenContentMetadata : BaseMetadata
|
||||
Optional<string> publisher,
|
||||
Optional<int> pageCount)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(title))
|
||||
return Errors.Metadata.TitleCannotBeEmpty;
|
||||
if (releaseInfo is null)
|
||||
return Errors.Metadata.ReleaseInfoCannotBeNull;
|
||||
if (genres is null)
|
||||
return Errors.Metadata.GenresListCannotBeNull;
|
||||
if (tags is null)
|
||||
return Errors.Metadata.TagsListCannotBeNull;
|
||||
return new WrittenContentMetadata(
|
||||
title,
|
||||
originalTitle,
|
||||
description,
|
||||
releaseInfo,
|
||||
genres, tags,
|
||||
language,
|
||||
originalLanguage,
|
||||
publisher,
|
||||
return string.IsNullOrWhiteSpace(title)
|
||||
? (ErrorOr<WrittenContentMetadata>)Errors.Metadata.TitleCannotBeEmpty
|
||||
: releaseInfo is null
|
||||
? (ErrorOr<WrittenContentMetadata>)Errors.Metadata.ReleaseInfoCannotBeNull
|
||||
: genres is null
|
||||
? (ErrorOr<WrittenContentMetadata>)Errors.Metadata.GenresListCannotBeNull
|
||||
: tags is null
|
||||
? (ErrorOr<WrittenContentMetadata>)Errors.Metadata.TagsListCannotBeNull
|
||||
: (ErrorOr<WrittenContentMetadata>)new WrittenContentMetadata(
|
||||
title,
|
||||
originalTitle,
|
||||
description,
|
||||
releaseInfo,
|
||||
genres, tags,
|
||||
language,
|
||||
originalLanguage,
|
||||
publisher,
|
||||
pageCount
|
||||
);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class WrittenContentMetadata : BaseMetadata
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
foreach (var component in base.GetEqualityComponents())
|
||||
foreach (object component in base.GetEqualityComponents())
|
||||
yield return component;
|
||||
yield return Publisher;
|
||||
yield return PageCount;
|
||||
|
||||
Reference in new issue
Block a user