mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-22 01:16:17 +08:00
a85f977ccf
HttpClient 统一到 HttpClientFactory
41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
using System.Application.Services;
|
|
using System.Application.Services.Implementation;
|
|
using System.Net.Http;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace Microsoft.Extensions.DependencyInjection
|
|
{
|
|
public static class ServiceCollectionExtensions
|
|
{
|
|
/// <summary>
|
|
/// 尝试添加模型验证
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <returns></returns>
|
|
public static IServiceCollection TryAddModelValidator(this IServiceCollection services)
|
|
{
|
|
services.TryAddSingleton<IModelValidator, ModelValidator>();
|
|
return services;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 尝试添加 <see cref="IHttpPlatformHelper"/>
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <returns></returns>
|
|
public static IServiceCollection TryAddHttpPlatformHelper(this IServiceCollection services)
|
|
{
|
|
services.TryAddSingleton<IHttpPlatformHelper, HttpPlatformHelper>();
|
|
return services;
|
|
}
|
|
|
|
//public static IServiceCollection AddHttpService(this IServiceCollection services, string name)
|
|
//{
|
|
// // 此函数为添加HTTP服务模板
|
|
// // https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/http-requests?view=aspnetcore-5.0
|
|
// services.AddHttpClient(name);
|
|
// services.AddSingleton<IXXHttpService, XXHttpService>();
|
|
//}
|
|
}
|
|
} |