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:
Developer 02 2025-12-05 23:54:16 +01:00
parent 10fc56b262
commit 91c8b98f44

View File

@ -66,9 +66,7 @@ namespace ReC.Client
Provider = Services.BuildServiceProvider();
}
public static ReCClient Static
{
get
public static ReCClient Create()
{
if (Provider == null)
throw new InvalidOperationException("Static Provider is not built. Call BuildStaticClient first.");
@ -76,7 +74,6 @@ namespace ReC.Client
var httpClientFactory = Provider.GetRequiredService<IHttpClientFactory>();
return new ReCClient(httpClientFactory);
}
}
#endregion
}
}