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.
|
|
|
|
using NzbDrone.Common.Serializer;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Indexers
|
|
|
|
|
{
|
|
|
|
|
public interface IProviderIndexerSetting
|
|
|
|
|
{
|
|
|
|
|
TSetting Get<TSetting>(IIndexer indexer) where TSetting : IIndexerSetting, new();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class IndexerSettingProvider : IProviderIndexerSetting
|
|
|
|
|
{
|
|
|
|
|
private readonly IIndexerRepository _indexerRepository;
|
|
|
|
|
|
|
|
|
|
public IndexerSettingProvider(IIndexerRepository indexerRepository)
|
|
|
|
|
{
|
|
|
|
|
_indexerRepository = indexerRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TSetting Get<TSetting>(IIndexer indexer) where TSetting : IIndexerSetting, new()
|
|
|
|
|
{
|
|
|
|
|
var indexerDef = _indexerRepository.Find(indexer.Name);
|
|
|
|
|
|
|
|
|
|
if (indexerDef == null || string.IsNullOrWhiteSpace(indexerDef.Settings))
|
|
|
|
|
{
|
|
|
|
|
return new TSetting();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Json.Deserialize<TSetting>(indexerDef.Settings);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|