You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
2.1 KiB
55 lines
2.1 KiB
using AuroraDesk.Core.Interfaces;
|
|
using AuroraDesk.Infrastructure.Services;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace AuroraDesk.Infrastructure.Extensions;
|
|
|
|
/// <summary>
|
|
/// 服务集合扩展方法(基础设施层)
|
|
/// </summary>
|
|
public static class ServiceCollectionExtensions
|
|
{
|
|
/// <summary>
|
|
/// 添加业务服务
|
|
/// </summary>
|
|
/// <param name="services">服务集合</param>
|
|
/// <returns>服务集合</returns>
|
|
public static IServiceCollection AddBusinessServices(this IServiceCollection services)
|
|
{
|
|
// 注册业务服务(接口在 Core 层,实现在 Infrastructure 层)
|
|
services.AddTransient<IDataService, DataService>();
|
|
services.AddTransient<IApiService, ApiService>();
|
|
|
|
// 注册资源服务
|
|
services.AddSingleton<IResourceService, ResourceService>();
|
|
|
|
// 注册图标服务(使用单例模式缓存图标数据)
|
|
services.AddSingleton<IIconService, IconService>();
|
|
|
|
return services;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加导航服务(必须在 AddViewModels 之后调用,因为 NavigationService 依赖 IPageViewModelFactory)
|
|
/// </summary>
|
|
/// <param name="services">服务集合</param>
|
|
/// <returns>服务集合</returns>
|
|
public static IServiceCollection AddNavigationService(this IServiceCollection services)
|
|
{
|
|
// 注册导航服务(接口在 Core 层,实现在 Infrastructure 层)
|
|
// 注意:需要在 Presentation 层的 AddViewModels 之后调用,因为它依赖 IPageViewModelFactory
|
|
services.AddTransient<INavigationService, NavigationService>();
|
|
|
|
// 注册导航状态管理服务(重构新增,分离状态管理职责)
|
|
services.AddTransient<INavigationStateService, NavigationStateService>();
|
|
|
|
// 注册标签页管理服务(重构新增,分离标签页管理职责)
|
|
services.AddTransient<ITabManagementService, TabManagementService>();
|
|
|
|
// 注册节点画布服务
|
|
services.AddSingleton<INodeCanvasService, NodeCanvasService>();
|
|
|
|
return services;
|
|
}
|
|
}
|
|
|
|
|