30 lines
892 B
C#
30 lines
892 B
C#
|
|
using guoke;
|
||
|
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
|
|
||
|
|
namespace WpfApp.Services
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 服务配置类
|
||
|
|
/// </summary>
|
||
|
|
public static class ServiceConfiguration
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 配置服务
|
||
|
|
/// </summary>
|
||
|
|
/// <returns>服务提供者</returns>
|
||
|
|
public static ServiceProvider ConfigureServices()
|
||
|
|
{
|
||
|
|
// 创建服务集合
|
||
|
|
var services = new ServiceCollection();
|
||
|
|
// 注册服务
|
||
|
|
services.AddSingleton<LogService>();//日志服务
|
||
|
|
services.AddSingleton(typeof(EventService<>));//事件服务
|
||
|
|
services.AddSingleton<DatabaseService>();//数据库服务
|
||
|
|
// 注册窗体
|
||
|
|
services.AddTransient<MainWindow>();
|
||
|
|
|
||
|
|
// 构建服务提供者
|
||
|
|
return services.BuildServiceProvider();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|