2019-10-12 21:37:16 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Security.Policy;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Downloaders
|
|
|
|
|
{
|
|
|
|
|
public static class DownloadDispatcher
|
|
|
|
|
{
|
|
|
|
|
private static List<IDownloader> _downloaders = new List<IDownloader>()
|
|
|
|
|
{
|
|
|
|
|
new MegaDownloader(),
|
|
|
|
|
new DropboxDownloader(),
|
|
|
|
|
new GoogleDriveDownloader(),
|
|
|
|
|
new HTTPDownloader(),
|
2019-10-12 22:15:20 +00:00
|
|
|
|
new NexusDownloader(),
|
|
|
|
|
new ManualDownloader()
|
2019-10-12 21:37:16 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private static Dictionary<Type, IDownloader> _indexedDownloaders;
|
|
|
|
|
|
|
|
|
|
static DownloadDispatcher()
|
|
|
|
|
{
|
|
|
|
|
_indexedDownloaders = _downloaders.ToDictionary(d => d.GetType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static T GetInstance<T>()
|
|
|
|
|
{
|
|
|
|
|
return (T)_indexedDownloaders[typeof(T)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static AbstractDownloadState ResolveArchive(dynamic ini)
|
|
|
|
|
{
|
|
|
|
|
foreach (var d in _downloaders)
|
|
|
|
|
{
|
|
|
|
|
var result = d.GetDownloaderState(ini);
|
|
|
|
|
if (result != null) return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|