using Microsoft.Extensions.DependencyInjection;
#if NETFRAMEWORK
using System;
using System.Net.Http;
#endif
namespace ReC.Client
{
///
/// Provides extension methods for setting up the ReC client in an .
///
public static class DependencyInjection
{
///
/// Adds and configures the for the to the specified
///
/// The to add the services to.
/// The base URI of the ReC API.
/// An that can be used to configure the client.
public static IHttpClientBuilder AddRecClient(this IServiceCollection services, string apiUri)
{
services.AddScoped();
return services.AddHttpClient(ReCClient.ClientName, client =>
{
client.BaseAddress = new Uri(apiUri);
});
}
///
/// Adds and configures the for the to the specified
///
/// The to add the services to.
/// An action to configure the .
/// An that can be used to configure the client.
public static IHttpClientBuilder AddRecClient(this IServiceCollection services, Action configureClient)
{
services.AddScoped();
return services.AddHttpClient(ReCClient.ClientName, configureClient);
}
}
}