public static void Register(IServiceCollection services, Microsoft.Extensions.Configuration.IConfiguration cfg, Action <Type> setMediator) { setMediator(typeof(CalculatorQueryHandler)); AsyncRetryPolicy retryPolicy = Policy .Handle <HttpRequestException>() .WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)) ); services.AddSingleton <AsyncRetryPolicy>(retryPolicy); var config = cfg.GetSection("services").Get <ServicesConfig>(); services.AddSingleton <ServicesConfig>(); services.AddScoped <IRateService, RateClient>(o => new RateClient( new HttpClient() { BaseAddress = cfg.Uri("RateServiceUrl") } )); }