/// <summary> /// Integrates ApiClient factoring /// </summary> public static IServiceCollection AddApiClients( this IServiceCollection services, Action <IApiContractRegistrar> contractRegistration, IHttpClientFactory clientFactory) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (clientFactory == null) { throw new ArgumentNullException(nameof(clientFactory)); } services.AddSingleton(clientFactory); if (contractRegistration != null) { var contractRegistrar = new DefaultApiContractRegistrar(services); contractRegistration(contractRegistrar); } return(services); }
/// <summary> /// Integrates ApiClient factoring /// </summary> public static IServiceCollection AddApiClients( this IServiceCollection services, Action <IApiContractRegistrar> contractRegistration, ApiClientsOptions options) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } HttpClientRegistrar.Register(services, options); if (contractRegistration != null) { var contractRegistrar = new DefaultApiContractRegistrar(services); contractRegistration(contractRegistrar); } return(services); }