From b0f5738390f99218c7ea513a32e6a29aaf8960e0 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Thu, 27 Jun 2024 16:02:41 +0200 Subject: [PATCH] Bedingung vom Typ new() entfernen --- DigitalData.Core.Abstractions/Client/IHttpClientService.cs | 1 - .../DigitalData.Core.Abstractions.csproj | 2 +- DigitalData.Core.Client/DIExtensions.cs | 2 +- DigitalData.Core.Client/DigitalData.Core.Client.csproj | 2 +- DigitalData.Core.Client/HttpClientOptions.cs | 2 +- DigitalData.Core.Client/HttpClientService.cs | 2 +- DigitalData.Core.Client/ServiceFactory.cs | 6 +++++- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/DigitalData.Core.Abstractions/Client/IHttpClientService.cs b/DigitalData.Core.Abstractions/Client/IHttpClientService.cs index 95973e5..e94aaed 100644 --- a/DigitalData.Core.Abstractions/Client/IHttpClientService.cs +++ b/DigitalData.Core.Abstractions/Client/IHttpClientService.cs @@ -1,7 +1,6 @@ namespace DigitalData.Core.Abstractions.Client { public interface IHttpClientService : IBaseHttpClientService - where TClientOptions : new() { } } \ No newline at end of file diff --git a/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj b/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj index 5a04fbf..4425771 100644 --- a/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj +++ b/DigitalData.Core.Abstractions/DigitalData.Core.Abstractions.csproj @@ -18,7 +18,7 @@ False aa-DJ Assets\icon.png - 1.0.1 + 1.0.1.1 diff --git a/DigitalData.Core.Client/DIExtensions.cs b/DigitalData.Core.Client/DIExtensions.cs index a328ddf..0d90794 100644 --- a/DigitalData.Core.Client/DIExtensions.cs +++ b/DigitalData.Core.Client/DIExtensions.cs @@ -18,7 +18,7 @@ namespace DigitalData.Core.Client } public static IServiceCollection AddHttpClientService(this IServiceCollection services, Action? clientOptions = null, bool setAsDefaultBase = false) - where TClientOptions : HttpClientOptions, new() + where TClientOptions : HttpClientOptions { services.TryAddSingleton(); services.TryAddSingleton(); diff --git a/DigitalData.Core.Client/DigitalData.Core.Client.csproj b/DigitalData.Core.Client/DigitalData.Core.Client.csproj index 66722d0..d54a8c7 100644 --- a/DigitalData.Core.Client/DigitalData.Core.Client.csproj +++ b/DigitalData.Core.Client/DigitalData.Core.Client.csproj @@ -6,7 +6,7 @@ enable This package provides HTTP client extension methods for the DigitalData.Core library, offering simplified and asynchronous methods for fetching and handling HTTP responses. It includes utility methods for sending GET requests, reading response content as text or JSON, and deserializing JSON into dynamic or strongly-typed objects using Newtonsoft.Json. These extensions facilitate efficient and easy-to-read HTTP interactions in client applications. DigitalData.Core.Client - 1.0.1 + 1.0.1.1 Digital Data GmbH Digital Data GmbH Digital Data GmbH diff --git a/DigitalData.Core.Client/HttpClientOptions.cs b/DigitalData.Core.Client/HttpClientOptions.cs index aa993d1..956014d 100644 --- a/DigitalData.Core.Client/HttpClientOptions.cs +++ b/DigitalData.Core.Client/HttpClientOptions.cs @@ -2,6 +2,6 @@ { public class HttpClientOptions { - public required string Uri { get; set; } + public string Uri { get; set; } = string.Empty; } } diff --git a/DigitalData.Core.Client/HttpClientService.cs b/DigitalData.Core.Client/HttpClientService.cs index cb00e43..e7543fb 100644 --- a/DigitalData.Core.Client/HttpClientService.cs +++ b/DigitalData.Core.Client/HttpClientService.cs @@ -5,7 +5,7 @@ using System.Net; namespace DigitalData.Core.Client { public class HttpClientService : BaseHttpClientService, IHttpClientService, IBaseHttpClientService - where TClientOptions : HttpClientOptions, new() + where TClientOptions : HttpClientOptions { public HttpClientService(HttpClient client, CookieContainer cookieContainer, IOptions clientOptions) : base(client, cookieContainer, clientOptions) { diff --git a/DigitalData.Core.Client/ServiceFactory.cs b/DigitalData.Core.Client/ServiceFactory.cs index 4ab537c..be87b3f 100644 --- a/DigitalData.Core.Client/ServiceFactory.cs +++ b/DigitalData.Core.Client/ServiceFactory.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.DependencyInjection; +using DigitalData.Core.Abstractions.Client; +using Microsoft.Extensions.DependencyInjection; namespace DigitalData.Core.Client { @@ -17,5 +18,8 @@ namespace DigitalData.Core.Client private static IServiceProvider Build() => _services.BuildServiceProvider(); public static T Provide() where T : notnull => _lazyProvider.Value.GetRequiredService(); + + public static IHttpClientService ProvideHttpClientService() where TOptions : notnull + => _lazyProvider.Value.GetRequiredService>(); } } \ No newline at end of file