public static void RegisterService(this IServiceCollection services, IConfiguration configuration) { services.AddSingleton <IValidationAttributeAdapterProvider, CpfValidationAttributeAdapterProvider>(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddScoped <IAspNetUser, AspNetUser>(); #region HttpServices services.AddTransient <HttpClientAuthorizationDelegatingHandler>(); services.AddHttpClient <IAuthenticatorService, AuthenticatorService>() .AddPolicyHandler(PollyExtensions.AwaitTry()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <ICatalogService, CatalogService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AddPolicyHandler(PollyExtensions.AwaitTry()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); services.AddHttpClient <ICartService, CartService>() .AddHttpMessageHandler <HttpClientAuthorizationDelegatingHandler>() .AddPolicyHandler(PollyExtensions.AwaitTry()) .AddTransientHttpErrorPolicy( p => p.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30))); #endregion }