mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 06:11:10 +00:00
Implements directory browser dialog, part 1: file system treeview
This commit is contained in:
1 parent
4a53348013
commit
4e4ecbbfca
318 files changed
+6012
-1184
No files matched your search
@@ -0,0 +1,31 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
|
||||
using Mapster;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Mapping configuration for file system directories between the domain object and the presentation object.
|
||||
/// </summary>
|
||||
public class DirectoryMappingConfig : IRegister
|
||||
{
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Registers the mapping configuration.
|
||||
/// </summary>
|
||||
/// <param name="config">The type adapter configuration.</param>
|
||||
public void Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.NewConfig<Directory, FileSystemTreeNodeResponse>()
|
||||
.Map(dest => dest.Name, src => src.Name)
|
||||
.Map(dest => dest.Path, src => src.Id.Path)
|
||||
.Map(dest => dest.ItemType, src => src.Type)
|
||||
.Map(dest => dest.IsExpanded, () => false)
|
||||
.Map(dest => dest.ChildrenLoaded, () => false)
|
||||
.Map(dest => dest.Children, src => src.Items)
|
||||
.MapToConstructor(true);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
|
||||
using Mapster;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Mapping configuration for file system files between the domain object and the presentation object.
|
||||
/// </summary>
|
||||
public class FileMappingConfig : IRegister
|
||||
{
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Registers the mapping configuration.
|
||||
/// </summary>
|
||||
/// <param name="config">The type adapter configuration.</param>
|
||||
public void Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.NewConfig<File, FileSystemTreeNodeResponse>()
|
||||
.Map(dest => dest.Name, src => src.Name)
|
||||
.Map(dest => dest.Path, src => src.Id.Path)
|
||||
.Map(dest => dest.ItemType, src => src.Type)
|
||||
.Map(dest => dest.IsExpanded, () => false)
|
||||
.Map(dest => dest.ChildrenLoaded, () => false)
|
||||
.MapToConstructor(true);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Enums.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
|
||||
using Mapster;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Mapping configuration for file system trees between the domain object and the presentation object.
|
||||
/// </summary>
|
||||
public class FileSystemTreeMappingConfig : IRegister
|
||||
{
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Registers the mapping configuration.
|
||||
/// </summary>
|
||||
/// <param name="config">The type adapter configuration.</param>
|
||||
public void Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.NewConfig<WindowsRootItem, FileSystemTreeNodeResponse>()
|
||||
.Map(dest => dest.Path, src => src.Id.Path)
|
||||
.Map(dest => dest.Name, src => src.Name)
|
||||
.Map(dest => dest.ItemType, src => FileSystemItemType.Root)
|
||||
.Map(dest => dest.IsExpanded, () => false);
|
||||
|
||||
config.NewConfig<FileSystemTreeNodeResponse, WindowsRootItem>()
|
||||
.MapWith(src => WindowsRootItem.Create(
|
||||
src.Path,
|
||||
src.Name,
|
||||
FileSystemItemStatus.Accessible)
|
||||
.Value);
|
||||
|
||||
config.NewConfig<UnixRootItem, FileSystemTreeNodeResponse>()
|
||||
.Map(dest => dest.Path, src => src.Id.Path)
|
||||
.Map(dest => dest.Name, src => src.Name)
|
||||
.Map(dest => dest.ItemType, src => FileSystemItemType.Root)
|
||||
.Map(dest => dest.IsExpanded, () => false);
|
||||
|
||||
config.NewConfig<FileSystemTreeNodeResponse, UnixRootItem>()
|
||||
.MapWith(src => UnixRootItem.Create(
|
||||
FileSystemItemStatus.Accessible)
|
||||
.Value);
|
||||
|
||||
config.NewConfig<FileSystemItem, FileSystemTreeNodeResponse>()
|
||||
.MapWith(src => new FileSystemTreeNodeResponse
|
||||
{
|
||||
Path = src.Id.Path,
|
||||
Name = src.Name,
|
||||
ItemType = src.Type,
|
||||
IsExpanded = false,
|
||||
ChildrenLoaded = false,
|
||||
Children = new List<FileSystemTreeNodeResponse>()
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
using Mapster;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Mapping configuration for file system paths between the domain object and the presentation object.
|
||||
/// </summary>
|
||||
public class PathSegmentMappingConfig : IRegister
|
||||
{
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Registers the mapping configuration.
|
||||
/// </summary>
|
||||
/// <param name="config">The type adapter configuration.</param>
|
||||
public void Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.NewConfig<PathSegment, PathSegmentResponse>()
|
||||
.Map(dest => dest.Path, src => src.Name)
|
||||
.MapToConstructor(true);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+9
-6
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Models.Books;
|
||||
using Lumina.Domain.Common.Enums;
|
||||
using Lumina.Contracts.Enums.BookLibrary;
|
||||
using Lumina.Contracts.Models.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
|
||||
@@ -8,6 +8,9 @@ using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
using Mapster;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary;
|
||||
@@ -24,7 +27,7 @@ public class BookMappingConfig : IRegister
|
||||
/// <param name="config">The type adapter configuration.</param>
|
||||
public void Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.NewConfig<Book, BookDto>()
|
||||
config.NewConfig<Book, BookModel>()
|
||||
.Map(dest => dest.Id, src => src.Id.Value)
|
||||
.Map(dest => dest.Title, src => src.Metadata.Title)
|
||||
.Map(dest => dest.OriginalTitle, src => src.Metadata.OriginalTitle.HasValue ? src.Metadata.OriginalTitle.Value : default)
|
||||
@@ -62,7 +65,7 @@ public class BookMappingConfig : IRegister
|
||||
.Map(dest => dest.Created, src => src.Created)
|
||||
.Map(dest => dest.Updated, src => src.Updated.HasValue ? src.Updated : null);
|
||||
|
||||
config.NewConfig<BookRating, BookRatingDto>()
|
||||
config.NewConfig<BookRating, BookRatingModel>()
|
||||
.Map(dest => dest.Value, src => src.Value)
|
||||
.Map(dest => dest.MaxValue, src => src.MaxValue)
|
||||
.Map(dest => dest.VoteCount, src => src.VoteCount.HasValue ? src.VoteCount.Value : default)
|
||||
@@ -71,8 +74,8 @@ public class BookMappingConfig : IRegister
|
||||
config.NewConfig<Optional<BookRatingSource>, BookRatingSource?>()
|
||||
.MapWith(src => src.HasValue ? src.Value : default);
|
||||
|
||||
// from BookDto to Book
|
||||
config.NewConfig<BookDto, Book>()
|
||||
// from BookModel to Book
|
||||
config.NewConfig<BookModel, Book>()
|
||||
.MapWith(src => Book.Create(
|
||||
BookId.Create(src.Id),
|
||||
WrittenContentMetadata.Create(
|
||||
|
||||
Reference in new issue
Block a user