Enhance ReC.Client library with new features and cleanup
- Added comprehensive XML documentation for `DependencyInjection` and `ReCClient` classes to improve code readability. - Introduced overload for `AddRecClient` to allow flexible `HttpClient` configuration. - Added static `BuildStaticClient` and `Create` methods for simplified client instantiation. - Marked synchronous `InvokeRecAction` method as obsolete to encourage asynchronous usage. - Updated `ReC.Client.csproj`: - Added `<DocumentationFile>` property for XML doc generation. - Downgraded `Microsoft.Extensions.Http` to version 8.0.0. - Removed `System.Text.Json` package reference. - Removed `System.Text.Json` dependency from `ReCClient.cs`. - Generated unique `HttpClient` name for `ReCClient` instances. - Performed general code cleanup and improved method remarks.
This commit is contained in:
@@ -6,8 +6,17 @@ using System.Net.Http;
|
||||
|
||||
namespace ReC.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides extension methods for setting up the ReC client in an <see cref="IServiceCollection"/>.
|
||||
/// </summary>
|
||||
public static class DependencyInjection
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds and configures the <see cref="HttpClient"/> for the <see cref="ReCClient"/> to the specified <see cref="IServiceCollection"/>
|
||||
/// </summary>
|
||||
/// <param name="services">The <see cref="IServiceCollection"/> to add the services to.</param>
|
||||
/// <param name="apiUri">The base URI of the ReC API.</param>
|
||||
/// <returns>An <see cref="IHttpClientBuilder"/> that can be used to configure the client.</returns>
|
||||
public static IHttpClientBuilder AddRecClient(this IServiceCollection services, string apiUri)
|
||||
{
|
||||
return services.AddHttpClient(ReCClient.ClientName, client =>
|
||||
@@ -16,6 +25,12 @@ namespace ReC.Client
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds and configures the <see cref="HttpClient"/> for the <see cref="ReCClient"/> to the specified <see cref="IServiceCollection"/>
|
||||
/// </summary>
|
||||
/// <param name="services">The <see cref="IServiceCollection"/> to add the services to.</param>
|
||||
/// <param name="configureClient">An action to configure the <see cref="HttpClient"/>.</param>
|
||||
/// <returns>An <see cref="IHttpClientBuilder"/> that can be used to configure the client.</returns>
|
||||
public static IHttpClientBuilder AddRecClient(this IServiceCollection services, Action<HttpClient> configureClient)
|
||||
{
|
||||
return services.AddHttpClient(ReCClient.ClientName, configureClient);
|
||||
|
||||
Reference in New Issue
Block a user