コード例 #1
0
        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);
        }
コード例 #2
0
 public ScraperService(
     ILogger <ScraperService> logger,
     ITvMazeHttpClient httpClient,
     MazeApiSettings mazeApiSettings,
     TvMazeScraperContext context)
 {
     _logger          = logger;
     _httpClient      = httpClient;
     _mazeApiSettings = mazeApiSettings;
     _context         = context;
 }
コード例 #3
0
 public TvMazeHttpClient(HttpClient httpClient, MazeApiSettings mazeapisettings)
 {
     _httpClient      = httpClient;
     _mazeApiSettings = mazeapisettings;
 }
コード例 #4
0
 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());
 }