public static IServiceCollection AddHttpDownloader(this IServiceCollection services) { services.TryAddTransient(provider => { var config = provider.GetRequiredService <Config>(); var client = HttpClientUtils.BuildClientForBilibili(config.UserAgent, config.Cookie, config.HttpHandler); return(new HttpDownloader(client)); }); services.TryAddTransient(provider => { var logger = provider.GetRequiredService <ILogger <MultiThreadedDownloader> >(); var config = provider.GetRequiredService <Config>(); var client = HttpClientUtils.BuildClientForMultiThreadedDownloader(config.Cookie, config.UserAgent, config.HttpHandler); return(new MultiThreadedDownloader(logger, client)); }); return(services); }