Initial commit: FluidExplorer:从零实现的 WinUI 3 文件资源管理器替代品(Mica、命令栏、面包屑)
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
using FluidExplorer.Services.FileSystem;
|
||||
using FluidExplorer.Services.Icons;
|
||||
using FluidExplorer.Services.Operations;
|
||||
using FluidExplorer.Services.Search;
|
||||
using FluidExplorer.ViewModels;
|
||||
using Microsoft.UI.Dispatching;
|
||||
|
||||
namespace FluidExplorer.Services;
|
||||
|
||||
/// <summary>组合根:所有服务在这里创建、装配,并交给视图模型。</summary>
|
||||
public sealed class AppServices
|
||||
{
|
||||
public AppServices(DispatcherQueue ui)
|
||||
{
|
||||
Ui = ui;
|
||||
Settings = AppSettings.Load();
|
||||
FileSystem = new FastFileSystemService();
|
||||
Search = new SearchService(FileSystem);
|
||||
Icons = CreateIconService(ui);
|
||||
Operations = CreateOperationService();
|
||||
Main = new MainViewModel(FileSystem, Search, Operations, Icons, Settings, ui);
|
||||
}
|
||||
|
||||
public DispatcherQueue Ui { get; }
|
||||
public AppSettings Settings { get; }
|
||||
public IFileSystemService FileSystem { get; }
|
||||
public SearchService Search { get; }
|
||||
public IIconService Icons { get; }
|
||||
public IFileOperationService Operations { get; }
|
||||
public MainViewModel Main { get; }
|
||||
|
||||
/// <summary>接入 Windows 外壳原版图标(imageres.dll / IShellItemImageFactory)。</summary>
|
||||
private static IIconService CreateIconService(DispatcherQueue ui)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new ShellIconService(ui);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new PlaceholderIconService();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>接入文件操作队列引擎。</summary>
|
||||
private static IFileOperationService CreateOperationService()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new FileOperationService();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new PlaceholderOperationService();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>接入 NTFS USN/MFT 索引(Everything 式极速搜索)。</summary>
|
||||
public void WireSearchIndex()
|
||||
{
|
||||
Search.IndexFactory = volumeRoot =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return new FluidExplorer.Services.Search.Usn.UsnVolumeIndex(volumeRoot);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 非 NTFS 卷等异常情况:该卷不建索引,搜索自动退化为实时扫描
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user