From 8cad1df95dd4b7eea3e5151ee64456685729c0d9 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Fri, 5 Dec 2025 23:23:17 +0100 Subject: [PATCH] Add DependencyInjection support for ReCClient Introduced a `DependencyInjection` class in the `ReC.Client` namespace to enable dependency injection for `ReCClient`. Added an `AddRecClient` extension method for `IServiceCollection` to register an `HttpClient` with a configurable `apiUri` as the base address. Included conditional `using System;` for .NET Framework compatibility and added `Microsoft.Extensions.DependencyInjection` to support DI services. --- src/ReC.Client/DependencyInjection.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/ReC.Client/DependencyInjection.cs diff --git a/src/ReC.Client/DependencyInjection.cs b/src/ReC.Client/DependencyInjection.cs new file mode 100644 index 0000000..8e12a67 --- /dev/null +++ b/src/ReC.Client/DependencyInjection.cs @@ -0,0 +1,18 @@ +using Microsoft.Extensions.DependencyInjection; +#if NETFRAMEWORK +using System; +#endif + +namespace ReC.Client +{ + public static class DependencyInjection + { + public static IHttpClientBuilder AddRecClient(this IServiceCollection services, string apiUri) + { + return services.AddHttpClient(ReCClient.ClientName, client => + { + client.BaseAddress = new Uri(apiUri); + }); + } + } +}