mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-22 09:36:09 +08:00
94 lines
3.2 KiB
C#
94 lines
3.2 KiB
C#
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
using Microsoft.Extensions.Logging;
|
|
using System.Application.Services;
|
|
using System.Application.Services.Implementation;
|
|
using System.Application.UI;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace Microsoft.Extensions.DependencyInjection
|
|
{
|
|
public static class ServiceCollectionExtensions
|
|
{
|
|
/// <summary>
|
|
/// 添加桌面端日志实现
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <returns></returns>
|
|
public static IServiceCollection AddDesktopLogging(this IServiceCollection services)
|
|
{
|
|
var (minLevel, cfg) = AppHelper.Configure();
|
|
services.AddLogging(cfg);
|
|
services.Configure<LoggerFilterOptions>(o =>
|
|
{
|
|
o.MinLevel = minLevel;
|
|
});
|
|
return services;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加业务用户配置文件服务
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <returns></returns>
|
|
public static IServiceCollection AddConfigFileService(this IServiceCollection services)
|
|
{
|
|
services.AddSingleton<IConfigFileService, ConfigFileServiceImpl>();
|
|
return services;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加 hosts 文件助手服务
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <returns></returns>
|
|
public static IServiceCollection AddHostsFileService(this IServiceCollection services)
|
|
{
|
|
services.AddSingleton<IHostsFileService, HostsFileServiceImpl>();
|
|
return services;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加 Steam 相关助手、工具类服务
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <returns></returns>
|
|
public static IServiceCollection AddSteamService(this IServiceCollection services)
|
|
{
|
|
services.AddSingleton<ISteamService, SteamServiceImpl>();
|
|
return services;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 尝试添加 Steamworks LocalApi Service
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <returns></returns>
|
|
public static IServiceCollection TryAddSteamworksLocalApiService(this IServiceCollection services)
|
|
{
|
|
services.TryAddSingleton<ISteamworksLocalApiService, SteamworksLocalApiServiceImpl>();
|
|
return services;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加 SteamDb WebApi Service
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <returns></returns>
|
|
public static IServiceCollection AddSteamDbWebApiService(this IServiceCollection services)
|
|
{
|
|
services.AddSingleton<ISteamDbWebApiService, SteamDbWebApiServiceImpl>();
|
|
return services;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加 Steamworks WebApi Service
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <returns></returns>
|
|
public static IServiceCollection AddSteamworksWebApiService(this IServiceCollection services)
|
|
{
|
|
services.AddSingleton<ISteamworksWebApiService, SteamworksWebApiServiceImpl>();
|
|
return services;
|
|
}
|
|
}
|
|
} |