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,9 +66,7 @@ namespace ReC.Client
|
|||||||
Provider = Services.BuildServiceProvider();
|
Provider = Services.BuildServiceProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReCClient Static
|
public static ReCClient Create()
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
{
|
||||||
if (Provider == null)
|
if (Provider == null)
|
||||||
throw new InvalidOperationException("Static Provider is not built. Call BuildStaticClient first.");
|
throw new InvalidOperationException("Static Provider is not built. Call BuildStaticClient first.");
|
||||||
@ -76,7 +74,6 @@ namespace ReC.Client
|
|||||||
var httpClientFactory = Provider.GetRequiredService<IHttpClientFactory>();
|
var httpClientFactory = Provider.GetRequiredService<IHttpClientFactory>();
|
||||||
return new ReCClient(httpClientFactory);
|
return new ReCClient(httpClientFactory);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user