Refactor: Verwenden Sie Lazy<HttpClient> in EConnectClient, um die Erstellung zu verzögern.
This commit is contained in:
parent
9117a23be3
commit
c6ec3ca054
@ -6,13 +6,13 @@ namespace Leanetec.EConnect.Infrastructure;
|
|||||||
|
|
||||||
public class EConnectClient<TError> : IEConnectClient<TError> where TError : class
|
public class EConnectClient<TError> : IEConnectClient<TError> where TError : class
|
||||||
{
|
{
|
||||||
private readonly IHttpClientFactory _httpFactory;
|
private readonly Lazy<HttpClient> LazyHttp;
|
||||||
|
|
||||||
private HttpClient Http => _httpFactory.CreateEConnectClient();
|
private HttpClient Http => LazyHttp.Value;
|
||||||
|
|
||||||
public EConnectClient(IHttpClientFactory httpFactory)
|
public EConnectClient(IHttpClientFactory httpFactory)
|
||||||
{
|
{
|
||||||
_httpFactory = httpFactory;
|
LazyHttp = new Lazy<HttpClient>(httpFactory.CreateEConnectClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Response<TData, TError>> GetAsync<TData>(string? route = null, CancellationToken cancel = default)
|
public async Task<Response<TData, TError>> GetAsync<TData>(string? route = null, CancellationToken cancel = default)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user