src/Kros.AspNetCore/Extensions/ServiceCollectionExtensions.cs
/// <summary>
/// Attempts to set proxy to HttpClient.
/// </summary>
/// <param name="services">DI container.</param>
/// <param name="configuration">App configuration. A configuration section called "Proxy" with "Address"
/// value is required.</param>
Attempts to set proxy to HttpClient.
Attempts to set proxy to HttpClient .
public static IServiceCollection SetProxy(this IServiceCollection services, IConfiguration configuration)
        {
            IConfigurationSection section = configuration.GetSection("Proxy");
            if (section.Exists())
            {
                WebProxy proxy = section.Get<WebProxy>();
                if (!string.IsNullOrEmpty(proxy.Address?.AbsolutePath))
                {
                    HttpClient.DefaultProxy = proxy;
                }
            }
            return services;
        }
public static IServiceCollection SetProxy ( this IServiceCollection services , IConfiguration configuration ) { IConfigurationSection section = configuration . GetSection ( " " ) ; if ( section . Exists ( ) ) { WebProxy proxy = section . Get < WebProxy > ( ) ; if ( ! string . IsNullOrEmpty ( proxy . Address ? . AbsolutePath ) ) { HttpClient . DefaultProxy = proxy ; } } return services ; }
Attempts to set proxy to HttpClient.
Attempts to set proxy to HttpClient .
IServiceCollection
this
configuration
IConfiguration
App configuration. A configuration section called "Proxy" with "Address"
value is required.
App configuration . A configuration section called " Proxy " with " Address " value is required .
services
None