public static MazeApiSettings AddMazeApiSettings(this IServiceCollection services, IConfiguration configuration) { var mazeApiSettings = new MazeApiSettings(); new ConfigureFromConfigurationOptions <MazeApiSettings>(configuration.GetSection("MazeApiSettings")).Configure(mazeApiSettings); services.AddSingleton(mazeApiSettings); return(mazeApiSettings); }
public ScraperService( ILogger <ScraperService> logger, ITvMazeHttpClient httpClient, MazeApiSettings mazeApiSettings, TvMazeScraperContext context) { _logger = logger; _httpClient = httpClient; _mazeApiSettings = mazeApiSettings; _context = context; }
public TvMazeHttpClient(HttpClient httpClient, MazeApiSettings mazeapisettings) { _httpClient = httpClient; _mazeApiSettings = mazeapisettings; }
public static void AddHttpClientWithPolicyHandler(this IServiceCollection services, MazeApiSettings mazeApiSettings) { services .AddHttpClient <ITvMazeHttpClient, TvMazeHttpClient>(client => { client.BaseAddress = new Uri(mazeApiSettings.BaseUrl); }) .AddPolicyHandler(PolicyHandler.WaitAndRetry()) .AddPolicyHandler(PolicyHandler.Timeout()); }