Refactor ReCClient for cleaner and more flexible design
- Removed unused `System.Xml.Linq` namespace import. - Simplified code by removing `#if NETFRAMEWORK` directives. - Added `ClientName` field to uniquely identify HTTP clients. - Updated constructor to use named HTTP client with `ClientName`. - Removed unused `_jsonOptions` field for better code clarity.
This commit is contained in:
parent
c0c0650fee
commit
4ee79d6cd8
@ -1,12 +1,9 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
using System;
|
using System;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#else
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace ReC.Client
|
namespace ReC.Client
|
||||||
@ -14,11 +11,12 @@ namespace ReC.Client
|
|||||||
public class ReCClient
|
public class ReCClient
|
||||||
{
|
{
|
||||||
private readonly HttpClient _http;
|
private readonly HttpClient _http;
|
||||||
private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions() { PropertyNameCaseInsensitive = true };
|
|
||||||
|
public static readonly string ClientName = Guid.NewGuid().ToString();
|
||||||
|
|
||||||
public ReCClient(IHttpClientFactory httpClientFactory)
|
public ReCClient(IHttpClientFactory httpClientFactory)
|
||||||
{
|
{
|
||||||
_http = httpClientFactory.CreateClient();
|
_http = httpClientFactory.CreateClient(ClientName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user