39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using Avalonia_Services.Core;
|
|
using Avalonia_Services.Endpoints;
|
|
using Avalonia_Services.Extensions;
|
|
using Avalonia_Services.Services;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Avalonia_PC.Views
|
|
{
|
|
/// <summary>
|
|
/// MainWindow 的分部类,负责路由注册和统一端点适配。
|
|
/// </summary>
|
|
public partial class MainWindow
|
|
{
|
|
/// <summary>
|
|
/// 统一端点适配器(替代原来的 _routes 字典)。
|
|
/// 所有端点在 Avalonia-Services/AppEndpoints.cs 中统一定义。
|
|
/// </summary>
|
|
private DesktopEndpointAdapter _endpointAdapter = null!;
|
|
|
|
/// <summary>
|
|
/// 服务容器,通过构造函数注入。
|
|
/// </summary>
|
|
private IServiceProvider _services = null!;
|
|
|
|
/// <summary>
|
|
/// 从 DI 获取统一端点集合并构建桌面适配器。
|
|
/// </summary>
|
|
private void RegisterRoutes()
|
|
{
|
|
// 从 DI 获取已构建的端点集合
|
|
var endpointCollection = _services.GetRequiredService<ServiceEndpointCollection>();
|
|
_endpointAdapter = endpointCollection.CreateAdapter(_services);
|
|
}
|
|
}
|
|
}
|