wabbajack/Wabbajack.Downloaders.Dispatcher/ServiceExtensions.cs

62 lines
2.1 KiB
C#
Raw Normal View History

using System.Collections.Generic;
2021-09-27 12:42:46 +00:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Wabbajack.Downloaders.Bethesda;
2021-09-27 12:42:46 +00:00
using Wabbajack.Downloaders.Http;
using Wabbajack.Downloaders.Interfaces;
2021-09-27 12:42:46 +00:00
using Wabbajack.Downloaders.IPS4OAuth2Downloader;
using Wabbajack.Downloaders.Manual;
2021-09-27 12:42:46 +00:00
using Wabbajack.Downloaders.MediaFire;
using Wabbajack.Downloaders.ModDB;
using Wabbajack.DTOs.JsonConverters;
using Wabbajack.Networking.WabbajackClientApi;
using Wabbajack.RateLimiter;
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
namespace Wabbajack.Downloaders;
public static class ServiceExtensions
2021-09-27 12:42:46 +00:00
{
public static IServiceCollection AddDownloadDispatcher(this IServiceCollection services, bool useLoginDownloaders = true, bool useProxyCache = true)
2021-09-27 12:42:46 +00:00
{
if (useLoginDownloaders)
{
services
.AddDTOConverters()
.AddDTOSerializer()
.AddGoogleDriveDownloader()
.AddHttpDownloader()
.AddMegaDownloader()
.AddMediaFireDownloader()
.AddModDBDownloader()
.AddNexusDownloader()
.AddIPS4OAuth2Downloaders()
.AddWabbajackCDNDownloader()
.AddGameFileDownloader()
.AddBethesdaDownloader()
.AddWabbajackClient()
.AddManualDownloader();
}
else
{
services
.AddDTOConverters()
.AddDTOSerializer()
.AddGoogleDriveDownloader()
.AddHttpDownloader()
.AddMegaDownloader()
.AddMediaFireDownloader()
.AddModDBDownloader()
.AddWabbajackCDNDownloader()
.AddWabbajackClient();
}
services.AddSingleton(s =>
new DownloadDispatcher(s.GetRequiredService<ILogger<DownloadDispatcher>>(),
s.GetRequiredService<IEnumerable<IDownloader>>(),
s.GetRequiredService<IResource<DownloadDispatcher>>(),
s.GetRequiredService<Client>(),
useProxyCache));
return services;
2021-09-27 12:42:46 +00:00
}
}