fix(Client.DIExtensions): Generischer Typ zur Injektion mehrerer Client-Dienste hinzugefügt
This commit is contained in:
parent
ea3d1312b8
commit
52a7664e57
@ -1,5 +1,4 @@
|
|||||||
using DigitalData.Core.Abstractions.Client;
|
using DigitalData.Core.Abstractions.Client;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
|||||||
@ -8,13 +8,14 @@ namespace DigitalData.Core.Client
|
|||||||
{
|
{
|
||||||
public static class DIExtensions
|
public static class DIExtensions
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddHttpClientService(this IServiceCollection services, IConfigurationSection? section = null)
|
public static IServiceCollection AddHttpClientService<THttpClientOptions>(this IServiceCollection services, IConfigurationSection? section = null)
|
||||||
|
where THttpClientOptions : HttpClientOptions
|
||||||
{
|
{
|
||||||
services.TryAddSingleton<HttpClient>();
|
services.TryAddSingleton<HttpClient>();
|
||||||
services.TryAddSingleton<CookieContainer>();
|
services.TryAddSingleton<CookieContainer>();
|
||||||
services.TryAddSingleton<IBaseHttpClientService, BaseHttpClientService>();
|
services.TryAddSingleton<IBaseHttpClientService, BaseHttpClientService>();
|
||||||
if(section is not null)
|
if(section is not null)
|
||||||
services.Configure<HttpClientOptions>(section);
|
services.Configure<THttpClientOptions>(section);
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ namespace DigitalData.Core.Client
|
|||||||
public class HttpClientService<TClientOptions> : BaseHttpClientService, IHttpClientService<TClientOptions>, IBaseHttpClientService
|
public class HttpClientService<TClientOptions> : BaseHttpClientService, IHttpClientService<TClientOptions>, IBaseHttpClientService
|
||||||
where TClientOptions : HttpClientOptions
|
where TClientOptions : HttpClientOptions
|
||||||
{
|
{
|
||||||
public HttpClientService(HttpClient client, CookieContainer cookieContainer, IOptions<TClientOptions> clientOptions) : base(client, cookieContainer, clientOptions)
|
public HttpClientService(HttpClient client, CookieContainer cookieContainer, IOptions<TClientOptions> clientOptions) : base(client, cookieContainer, clientOptions.Value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user