You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Radarr/src/NzbDrone.Core/Download/DownloadClientProvider.cs

39 lines
1.2 KiB

using System.Linq;
using System.Collections.Generic;
using NzbDrone.Core.Indexers;
12 years ago
namespace NzbDrone.Core.Download
{
public interface IProvideDownloadClient
{
IDownloadClient GetDownloadClient(DownloadProtocol downloadProtocol);
IEnumerable<IDownloadClient> GetDownloadClients();
IDownloadClient Get(int id);
12 years ago
}
public class DownloadClientProvider : IProvideDownloadClient
{
private readonly IDownloadClientFactory _downloadClientFactory;
12 years ago
public DownloadClientProvider(IDownloadClientFactory downloadClientFactory)
12 years ago
{
_downloadClientFactory = downloadClientFactory;
12 years ago
}
public IDownloadClient GetDownloadClient(DownloadProtocol downloadProtocol)
12 years ago
{
return _downloadClientFactory.GetAvailableProviders().FirstOrDefault(v => v.Protocol == downloadProtocol);
}
public IEnumerable<IDownloadClient> GetDownloadClients()
{
return _downloadClientFactory.GetAvailableProviders();
12 years ago
}
public IDownloadClient Get(int id)
{
return _downloadClientFactory.GetAvailableProviders().Single(d => d.Definition.Id == id);
}
12 years ago
}
}