Refactor ReCClient.Static to Create() method
Replaced the `ReCClient.Static` property with a `ReCClient.Create()` method to improve clarity and align with best practices. The new method retains the same functionality, including throwing an `InvalidOperationException` if the `Provider` is not built. The logic for retrieving the `IHttpClientFactory` and creating a `ReCClient` instance remains unchanged.
This commit is contained in:
parent
10fc56b262
commit
91c8b98f44
@ -66,16 +66,13 @@ namespace ReC.Client
|
||||
Provider = Services.BuildServiceProvider();
|
||||
}
|
||||
|
||||
public static ReCClient Static
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Provider == null)
|
||||
throw new InvalidOperationException("Static Provider is not built. Call BuildStaticClient first.");
|
||||
public static ReCClient Create()
|
||||
{
|
||||
if (Provider == null)
|
||||
throw new InvalidOperationException("Static Provider is not built. Call BuildStaticClient first.");
|
||||
|
||||
var httpClientFactory = Provider.GetRequiredService<IHttpClientFactory>();
|
||||
return new ReCClient(httpClientFactory);
|
||||
}
|
||||
var httpClientFactory = Provider.GetRequiredService<IHttpClientFactory>();
|
||||
return new ReCClient(httpClientFactory);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user