From 91c8b98f44f2262ff3011ab136e6efe0ad0f14ff Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Fri, 5 Dec 2025 23:54:16 +0100 Subject: [PATCH] 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. --- src/ReC.Client/ReCClient.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/ReC.Client/ReCClient.cs b/src/ReC.Client/ReCClient.cs index 586f5fc..bde38c9 100644 --- a/src/ReC.Client/ReCClient.cs +++ b/src/ReC.Client/ReCClient.cs @@ -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(); - return new ReCClient(httpClientFactory); - } + var httpClientFactory = Provider.GetRequiredService(); + return new ReCClient(httpClientFactory); } #endregion }