Adds Domain layer unit tests for file system browser dialog

This commit is contained in:
BinaryAlley committed 2024-10-06 12:07:01 +03:00
1 parent 33f5936ab9
commit 45e9911363
58 files changed
+8880 -148

No files matched your search

@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -16,4 +16,5 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("EACBCFD4-0FDD-4819-B2F2-056C812B2A3F")]
[assembly: InternalsVisibleTo("Lumina.Application.UnitTests")]
[assembly: InternalsVisibleTo("Lumina.Application.UnitTests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
@@ -1,24 +1,87 @@
namespace Lumina.Contracts.Enums.PhotoLibrary;
namespace Lumina.Contracts.Enums.PhotoLibrary;
/// <summary>
/// Enumeration for known image types.
/// </summary>
public enum ImageType
{
/// <summary>
/// No image type specified.
/// </summary>
None,
/// <summary>
/// Bitmap image format.
/// </summary>
BMP,
/// <summary>
/// Graphics Interchange Format (GIF).
/// </summary>
GIF,
/// <summary>
/// Portable Network Graphics (PNG) format.
/// </summary>
PNG,
/// <summary>
/// Tagged Image File Format (TIFF).
/// </summary>
TIFF,
/// <summary>
/// Joint Photographic Experts Group (JPEG) format.
/// </summary>
JPEG,
/// <summary>
/// Canon-specific JPEG format.
/// </summary>
JPEG_CANON,
/// <summary>
/// Unknown JPEG format.
/// </summary>
JPEG_UNKNOWN,
/// <summary>
/// Macintosh Picture (PICT) format.
/// </summary>
PICT,
/// <summary>
/// Icon (ICO) format.
/// </summary>
ICO,
/// <summary>
/// Photoshop Document (PSD) format.
/// </summary>
PSD,
/// <summary>
/// JPEG 2000 format.
/// </summary>
JPEG2000,
/// <summary>
/// AV1 Image File Format (AVIF).
/// </summary>
AVIF,
/// <summary>
/// Web Picture (WEBP) format.
/// </summary>
WEBP,
/// <summary>
/// Truevision TGA format.
/// </summary>
TGA,
SVG,
}
/// <summary>
/// Scalable Vector Graphics (SVG) format.
/// </summary>
SVG
}
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -16,4 +16,5 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("F50EC9A6-696C-461E-B2F1-95B70BFE3DBF")]
[assembly: InternalsVisibleTo("Lumina.DataAccess.UnitTests")]
[assembly: InternalsVisibleTo("Lumina.DataAccess.UnitTests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
@@ -1,10 +1,12 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.IO.Abstractions;
using System.Runtime.InteropServices;
#endregion
namespace Lumina.Domain.Common.DependencyInjection;
@@ -38,8 +40,9 @@ public static class DomainLayerServices
services.AddScoped<IPlatformContextManager, PlatformContextManager>();
services.AddScoped<IUnixPathStrategy, UnixPathStrategy>();
services.AddScoped<IWindowsPathStrategy, WindowsPathStrategy>();
services.AddScoped<IOperatingSystemInfo, OperatingSystemInfo>();
services.AddSingleton<IFileSystem, FileSystem>();
return services;
}
#endregion
}
}
@@ -143,9 +143,9 @@ public class DirectoryService : IDirectoryService
ErrorOr<FileSystemPathId> newDirectoryPathResult = _environmentContext.DirectoryProviderService.CreateDirectory(path, name);
if (newDirectoryPathResult.IsError)
return newDirectoryPathResult.Errors;
ErrorOr<string> dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(path);
ErrorOr<Optional<DateTime>> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(path);
ErrorOr<Optional<DateTime>> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(path);
ErrorOr<string> dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(newDirectoryPathResult.Value);
ErrorOr<Optional<DateTime>> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(newDirectoryPathResult.Value);
ErrorOr<Optional<DateTime>> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(newDirectoryPathResult.Value);
// if any error occurred, mark directory as Inaccessible
if (dirNameResult.IsError || dateModifiedResult.IsError || dateCreatedResult.IsError)
{
@@ -159,18 +159,17 @@ internal class FileProviderService : IFileProviderService
// check if the source file exists
if (!_fileSystem.File.Exists(sourceFilePath.Path))
return Errors.FileManagement.FileNotFound;
string destinationFilePath;
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(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(destinationDirectoryPath.Path + fileName))
if (_fileSystem.File.Exists(destinationFilePath))
if (!overrideExisting)
return Errors.FileManagement.FileAlreadyExists;
destinationFilePath = destinationDirectoryPath.Path + fileName;
}
try
{
@@ -218,7 +217,7 @@ internal class FileProviderService : IFileProviderService
try
{
string fileName = _fileSystem.Path.GetFileName(sourceFilePath.Path);
string destinationFilePath = destinationDirectoryPath.Path + fileName;
string destinationFilePath = _fileSystem.Path.Combine(destinationDirectoryPath.Path, fileName);
// if the destination file does not exist, perform a simple move
if (!_fileSystem.File.Exists(destinationFilePath))
_fileSystem.File.Move(sourceFilePath.Path, destinationFilePath);
@@ -117,6 +117,8 @@ public class FileService : IFileService
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a copied file, or an error.</returns>
public ErrorOr<File> CopyFile(string sourceFilePath, string destinationDirectoryPath, bool? overrideExisting)
{
if (string.IsNullOrWhiteSpace(destinationDirectoryPath))
return Errors.FileManagement.InvalidPath;
// make sure the paths are in the expected format
if (!destinationDirectoryPath.EndsWith(_platformContext.PathStrategy.PathSeparator))
destinationDirectoryPath += _platformContext.PathStrategy.PathSeparator;
@@ -181,6 +183,8 @@ public class FileService : IFileService
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a moved file, or an error.</returns>
public ErrorOr<File> MoveFile(string sourceFilePath, string destinationDirectoryPath, bool? overrideExisting)
{
if (string.IsNullOrWhiteSpace(destinationDirectoryPath))
return Errors.FileManagement.InvalidPath;
// make sure the paths are in the expected format
if (!destinationDirectoryPath.EndsWith(_platformContext.PathStrategy.PathSeparator))
destinationDirectoryPath += _platformContext.PathStrategy.PathSeparator;
@@ -1,4 +1,4 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
@@ -16,7 +16,7 @@ namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.S
/// <summary>
/// Service for file system permissions.
/// </summary>
internal class FileSystemPermissionsService : IFileSystemPermissionsService
internal class FileSystemPermissionsService : IFileSystemPermissionsService // TODO: refactor towards abstractions that could allow testing
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IPlatformContextManager _platformContextManager;
@@ -210,4 +210,4 @@ internal class FileSystemPermissionsService : IFileSystemPermissionsService
return allowAccess;
}
#endregion
}
}
@@ -23,7 +23,7 @@ public class FileTypeService : IFileTypeService
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IFileSystem _fileSystem;
private readonly IFileSystemPermissionsService _fileSystemPermissionsService;
private const int BUFFER_SIZE = 16; // 16 bytes should be more than enough for common images header types
private const int BUFFER_SIZE = 18; // 18 bytes should be more than enough for common images header types
#endregion
#region ====================================================================== CTOR =====================================================================================
@@ -119,7 +119,7 @@ public class FileTypeService : IFileTypeService
if (buffer.Length < 18)
return false;
byte imageType = buffer[2];
return imageType is 1 or 2 or 10;
return imageType is 1 or 2 or 3 or 9 or 10 or 11;
}
/// <summary>
@@ -1,5 +1,6 @@
#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 System.Collections.Generic;
@@ -69,6 +70,8 @@ public class PathService : IPathService
/// <returns>An <see cref="ErrorOr{TValue}"/> containing the combined path, or an error.</returns>
public ErrorOr<string> CombinePath(string path, string name)
{
if (string.IsNullOrWhiteSpace(path) || string.IsNullOrWhiteSpace(name))
return Errors.FileManagement.InvalidPath;
ErrorOr<FileSystemPathId> newPathResult = FileSystemPathId.Create(path);
if (newPathResult.IsError)
return newPathResult.Errors;
@@ -4,7 +4,6 @@ using Lumina.Domain.Common.Errors;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO.Abstractions;
using System.Linq;
using System.Text.RegularExpressions;
@@ -50,7 +49,7 @@ public class WindowsPathStrategy : IWindowsPathStrategy
return false;
// regular expression to match valid absolute paths
// this allows drive letters (e.g., C:\) and UNC paths (e.g., \\server\share)
string 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()._-]+)(?:[a-zA-Z0-9\s()._-]+\\)*[a-zA-Z0-9\s()._-]*\\?$";
return Regex.IsMatch(path.Path, pathPattern);
}
@@ -89,8 +88,8 @@ public class WindowsPathStrategy : IWindowsPathStrategy
/// <returns>An <see cref="ErrorOr{TValue}"/> containing the path segments, or an error.</returns>
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)
// 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;
IEnumerable<ErrorOr<PathSegment>> getPathSegmentsResults = GetPathSegments();
foreach (ErrorOr<PathSegment> getPathSegmentsResult in getPathSegmentsResults)
@@ -99,20 +98,39 @@ public class WindowsPathStrategy : IWindowsPathStrategy
return ErrorOrFactory.From(getPathSegmentsResults.Select(getPathSegmentsResult => getPathSegmentsResult.Value));
IEnumerable<ErrorOr<PathSegment>> GetPathSegments()
{
// the drive segment
yield return PathSegment.Create(path.Path[..2], isDirectory: false, isDrive: true);
// extract the other segments
string[] segments = path.Path[3..].Split(new[] { PathSeparator }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < segments.Length; i++)
if (path.Path.StartsWith(@"\\"))
{
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
else
isDirectory = true;
yield return PathSegment.Create(segment, isDirectory, isDrive: false);
// handle UNC path
yield return PathSegment.Create(@"\\", isDirectory: false, isDrive: true);
string[] segments = path.Path[2..].Split(new[] { PathSeparator }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < segments.Length; i++)
yield return CreatePathSegment(segments[i], i, segments.Length);
}
else // handle regular Windows path
{
// the drive segment
yield return PathSegment.Create(path.Path[..2], isDirectory: false, isDrive: true);
// extract the other segments
string[] segments = path.Path[3..].Split(new[] { PathSeparator }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < segments.Length; 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
else
isDirectory = true;
yield return PathSegment.Create(segment, isDirectory, isDrive: false);
}
}
}
ErrorOr<PathSegment> CreatePathSegment(string segment, int index, int totalSegments)
{
bool isDirectory = segment.Contains('.')
? index != totalSegments - 1 || path.Path.EndsWith(PathSeparator)
: true;
return PathSegment.Create(segment, isDirectory, isDrive: false);
}
}
@@ -126,22 +144,30 @@ public class WindowsPathStrategy : IWindowsPathStrategy
// validation: ensure the path is not null or empty
if (!IsValidPath(path))
return Errors.FileManagement.InvalidPath;
// if path is just a drive letter followed by ":\", return null
if (Regex.IsMatch(path.Path, @"^[a-zA-Z]:\\?$"))
// trim trailing backslash for consistent processing
string tempPath = path.Path.TrimEnd(PathSeparator);
// check for UNC path
if (tempPath.StartsWith(@"\\"))
{
string[] parts = tempPath.Split(PathSeparator, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length <= 2)
return Errors.FileManagement.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;
// trim trailing slash for consistent processing
string tempPath = path.Path;
if (tempPath.EndsWith('\\'))
tempPath = tempPath.TrimEnd(PathSeparator);
// find the last occurrence of a slash
// find the last occurrence of a backslash
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 there's no backslash found or it's at the root level, return the root
if (lastIndex <= 2)
return ParsePath(FileSystemPathId.Create(tempPath[..3]).Value);
// return the path up to the last backslash
ErrorOr<FileSystemPathId> newPathResult = FileSystemPathId.Create(tempPath[..lastIndex]);
if (newPathResult.IsError)
return newPathResult.Errors;
return ParsePath(newPathResult.Value);
}
@@ -163,28 +189,30 @@ public class WindowsPathStrategy : IWindowsPathStrategy
{
if (!IsValidPath(path))
return Errors.FileManagement.InvalidPath;
// check if the path starts with a drive letter (e.g., "C:")
if (path.Path.Length >= 2 && char.IsLetter(path.Path[0]) && path.Path[1] == ':')
// handle UNC paths (e.g., \\server\share\folder)
if (path.Path.StartsWith(@"\\"))
{
string root = path.Path[..2];
if (path.Path.Length > 2 && path.Path[2] == PathSeparator)
root += PathSeparator;
return PathSegment.Create(root, isDirectory: true, isDrive: true);
// 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
// find the position of the third backslash (after \\server\share)
int thirdBackslash = path.Path.IndexOf('\\', secondBackslash + 1);
if (thirdBackslash == -1)
thirdBackslash = path.Path.Length; // no third backslash, use entire path
// return the UNC root (\\server\share\)
return PathSegment.Create(path.Path[..thirdBackslash] + "\\", isDirectory: true, isDrive: false);
}
// check for UNC paths (e.g., "\\server\share")
if (path.Path.StartsWith('\\'))
{
ErrorOr<IEnumerable<PathSegment>> parseResult = ParsePath(path);
if (parseResult.IsError)
return parseResult.Errors;
List<PathSegment> segments = parseResult.Value.ToList();
if (segments.Count >= 2)
{
string root = $@"\\{segments[0].Name}\{segments[1].Name}\";
return PathSegment.Create(root, 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:\)
}
// if we reach here, the path is neither a valid UNC path nor a valid drive path
return Errors.FileManagement.InvalidPath;
}
#endregion
@@ -0,0 +1,20 @@
#region ========================================================================= USING =====================================================================================
using System.Runtime.InteropServices;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
/// <summary>
/// Interface for checking the type of the current Operating System platform.
/// </summary>
public interface IOperatingSystemInfo
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Determines if the current Operating System plaform is <paramref name="platform"/>.
/// </summary>
/// <param name="platform">The Operating System platform to check against.</param>
/// <returns><see langword="true"/> if tthe current Operating System platform is equal to <paramref name="platform"/>, <see langword="false"/> otherwise.</returns>
bool IsOSPlatform(OSPlatform platform);
#endregion
}
@@ -0,0 +1,25 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
/// <summary>
/// Class for checking the type of the current Operating System platform.
/// </summary>
[ExcludeFromCodeCoverage]
internal class OperatingSystemInfo : IOperatingSystemInfo
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Determines if the current Operating System plaform is <paramref name="platform"/>.
/// </summary>
/// <param name="platform">The Operating System platform to check against.</param>
/// <returns><see langword="true"/> if tthe current Operating System platform is equal to <paramref name="platform"/>, <see langword="false"/> otherwise.</returns>
public bool IsOSPlatform(OSPlatform platform)
{
return RuntimeInformation.IsOSPlatform(platform);
}
#endregion
}
@@ -1,4 +1,4 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using System;
using System.Runtime.InteropServices;
@@ -14,6 +14,7 @@ public class PlatformContextManager : IPlatformContextManager
#region ================================================================== FIELD MEMBERS ================================================================================
private IPlatformContext? _currentPlatformContext;
private readonly IPlatformContextFactory _platformContextFactory;
private readonly IOperatingSystemInfo _operatingSystemInfo;
#endregion
#region ====================================================================== CTOR =====================================================================================
@@ -21,9 +22,11 @@ public class PlatformContextManager : IPlatformContextManager
/// Initializes a new instance of the <see cref="PlatformContextManager"/> class.
/// </summary>
/// <param name="platformContextFactory">Injected factory for creating platform contexts.</param>
public PlatformContextManager(IPlatformContextFactory platformContextFactory)
/// <param name="operatingSystemInfo">Injected class for checking the platform type of the current Operating System.</param>
public PlatformContextManager(IPlatformContextFactory platformContextFactory, IOperatingSystemInfo operatingSystemInfo)
{
_platformContextFactory = platformContextFactory;
_operatingSystemInfo = operatingSystemInfo;
}
#endregion
@@ -37,7 +40,7 @@ public class PlatformContextManager : IPlatformContextManager
// set a default context if none is set
if (_currentPlatformContext is null)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
if (_operatingSystemInfo.IsOSPlatform(OSPlatform.Linux))
SetCurrentPlatform(PlatformType.Unix);
else
SetCurrentPlatform(PlatformType.Windows);
@@ -61,4 +64,4 @@ public class PlatformContextManager : IPlatformContextManager
};
}
#endregion
}
}
@@ -1,4 +1,4 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
#endregion
@@ -19,7 +19,7 @@ internal class UnixPlatformContext : IUnixPlatformContext
/// <summary>
/// Gets the path strategy for Unix platforms.
/// </summary>
public IPathStrategy PathStrategy { get; private set; }
public IPathStrategy PathStrategy { get; }
#endregion
#region ====================================================================== CTOR =====================================================================================
@@ -32,4 +32,4 @@ internal class UnixPlatformContext : IUnixPlatformContext
PathStrategy = unixPathStrategy;
}
#endregion
}
}
@@ -1,4 +1,4 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Path;
#endregion
@@ -19,7 +19,7 @@ public class WindowsPlatformContext : IWindowsPlatformContext
/// <summary>
/// Gets the path strategy for Windows platforms.
/// </summary>
public IPathStrategy PathStrategy { get; private set; }
public IPathStrategy PathStrategy { get; }
#endregion
#region ====================================================================== CTOR =====================================================================================
@@ -32,4 +32,4 @@ public class WindowsPlatformContext : IWindowsPlatformContext
PathStrategy = windowsPathStrategy;
}
#endregion
}
}
@@ -1,52 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Models.Core;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
/// <summary>
/// Value Object for the Id of a book.
/// </summary>
[DebuggerDisplay("{Value}")]
public sealed class FileSystemId : EntityId<Guid>
{
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="FileSystemId"/> class.
/// </summary>
/// <param name="value">The value representing this object.</param>
private FileSystemId(Guid value) : base(value)
{
}
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Creates a new instance of the <see cref="FileSystemId"/> class.
/// </summary>
/// <returns>The created <see cref="FileSystemId"/> instance.</returns>
public static FileSystemId CreateUnique()
{
return new FileSystemId(Guid.NewGuid());
}
/// <summary>
/// Creates a new instance of the <see cref="FileSystemId"/> class, from a pre-existing <paramref name="value"/>.
/// </summary>
/// <param name="value">The value used to create the <see cref="FileSystemId"/> instance.</param>
/// <returns>The created <see cref="FileSystemId"/> instance.</returns>
public static FileSystemId Create(Guid value)
{
return new FileSystemId(value);
}
/// <inheritdoc/>
public override IEnumerable<object> GetEqualityComponents()
{
yield return Value;
}
#endregion
}
+3 -2
View File
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -16,4 +16,5 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("E4C6366D-8187-459B-BB7F-1BE077DCFB25")]
[assembly: InternalsVisibleTo("Lumina.Domain.UnitTests")]
[assembly: InternalsVisibleTo("Lumina.Domain.UnitTests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -16,4 +16,5 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("EADA449A-48B9-4A97-97E8-73D23E9EC56A")]
[assembly: InternalsVisibleTo("Lumina.Infrastructure.UnitTests")]
[assembly: InternalsVisibleTo("Lumina.Infrastructure.UnitTests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -16,4 +16,5 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("D910C582-3905-4DD3-8BCA-0CB30852704E")]
[assembly: InternalsVisibleTo("Lumina.Presentation.Api.UnitTests")]
[assembly: InternalsVisibleTo("Lumina.Presentation.Api.UnitTests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
@@ -17,3 +17,4 @@ using System.Runtime.InteropServices;
[assembly: Guid("4E3EEA67-7C92-4588-9183-03140627D564")]
[assembly: InternalsVisibleTo("Lumina.Presentation.Web.UnitTests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]