refactor(HttpClientOptions): entfernt und durch IHttpClientOptions mit Klasseneinschränkung ersetzt

This commit is contained in:
Developer 02 2024-11-25 11:19:41 +01:00
parent f602a842be
commit ef7da0e52c
4 changed files with 3 additions and 18 deletions

View File

@ -19,7 +19,7 @@ namespace DigitalData.Core.Client
protected IEnumerable<KeyValuePair<string, object?>>? _queryParams;
public BaseHttpClientService(HttpClient client, CookieContainer cookieContainer, HttpClientOptions clientOptions)
public BaseHttpClientService(HttpClient client, CookieContainer cookieContainer, IHttpClientOptions clientOptions)
{
_client = client;
_cookies = cookieContainer;

View File

@ -9,7 +9,7 @@ namespace DigitalData.Core.Client
public static class DIExtensions
{
public static IServiceCollection AddHttpClientService<THttpClientOptions>(this IServiceCollection services, IConfigurationSection? section = null)
where THttpClientOptions : HttpClientOptions
where THttpClientOptions : class, IHttpClientOptions
{
services.TryAddSingleton<HttpClient>();
services.TryAddSingleton<CookieContainer>();

View File

@ -1,15 +0,0 @@
using DigitalData.Core.Abstractions.Client;
namespace DigitalData.Core.Client
{
public class HttpClientOptions : IHttpClientOptions
{
public required string Uri { get; init; }
public string? Path { get; init; }
public IEnumerable<KeyValuePair<string, object>>? Headers { get; init; }
public IEnumerable<KeyValuePair<string, object?>>? QueryParams { get; init; }
}
}

View File

@ -5,7 +5,7 @@ using System.Net;
namespace DigitalData.Core.Client
{
public class HttpClientService<TClientOptions> : BaseHttpClientService, IHttpClientService<TClientOptions>, IBaseHttpClientService
where TClientOptions : HttpClientOptions
where TClientOptions : class, IHttpClientOptions
{
public HttpClientService(HttpClient client, CookieContainer cookieContainer, IOptions<TClientOptions> clientOptions) : base(client, cookieContainer, clientOptions.Value)
{