From e0c2aab2b1b9470fcd41ddae3478c1b23c7994a2 Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 19 May 2026 19:20:28 +0200 Subject: [PATCH] Add support for configurable options in ReCClient Updated `ReCClient` to support dependency injection for `IOptions` and `ILogger`. Modified the constructor to include an optional `IOptions` parameter, allowing the use of configurable client options with default values when omitted. Updated API component initialization to pass `ReCClientOptions` for enhanced configuration. Added `Microsoft.Extensions.Logging` and `Microsoft.Extensions.Options` to `using` directives. Ensured compatibility with both `NETFRAMEWORK` and other target frameworks by updating constructor signatures accordingly. --- src/ReC.Client/ReCClient.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/ReC.Client/ReCClient.cs b/src/ReC.Client/ReCClient.cs index 907d641..5ed7410 100644 --- a/src/ReC.Client/ReCClient.cs +++ b/src/ReC.Client/ReCClient.cs @@ -1,5 +1,6 @@ -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using System; using System.Net.Http; using ReC.Client.Api; @@ -57,21 +58,23 @@ namespace ReC.Client /// Initializes a new instance of the class. /// /// The factory to create HttpClients. + /// An optional set of client options. Defaults are used when omitted. /// An optional logger used to record API call outcomes. #if NETFRAMEWORK - public ReCClient(IHttpClientFactory httpClientFactory, ILogger logger = null) + public ReCClient(IHttpClientFactory httpClientFactory, IOptions options = null, ILogger logger = null) #else - public ReCClient(IHttpClientFactory httpClientFactory, ILogger? logger = null) + public ReCClient(IHttpClientFactory httpClientFactory, IOptions? options = null, ILogger? logger = null) #endif { _http = httpClientFactory.CreateClient(ClientName); - RecActions = new RecActionApi(_http, logger); - Results = new ResultApi(_http, logger); - Profiles = new ProfileApi(_http, logger); - EndpointAuth = new EndpointAuthApi(_http, logger); - EndpointParams = new EndpointParamsApi(_http, logger); - Endpoints = new EndpointsApi(_http, logger); - Common = new CommonApi(_http, logger); + var opts = options?.Value ?? new ReCClientOptions(); + RecActions = new RecActionApi(_http, logger, opts); + Results = new ResultApi(_http, logger, opts); + Profiles = new ProfileApi(_http, logger, opts); + EndpointAuth = new EndpointAuthApi(_http, logger, opts); + EndpointParams = new EndpointParamsApi(_http, logger, opts); + Endpoints = new EndpointsApi(_http, logger, opts); + Common = new CommonApi(_http, logger, opts); } #region Static