Radarr/NzbDrone.Core/Indexers/IndexerSettingProvider.cs

25 lines
763 B
C#
Raw Normal View History

2013-04-07 07:30:37 +00:00
using Newtonsoft.Json;
namespace NzbDrone.Core.Indexers
{
public interface IProviderIndexerSetting
{
TSetting Get<TSetting>(IIndexerBase indexer) where TSetting : IIndexerSetting, new();
}
public class IndexerSettingProvider : IProviderIndexerSetting
{
private readonly IIndexerRepository _indexerRepository;
public IndexerSettingProvider(IIndexerRepository indexerRepository)
{
_indexerRepository = indexerRepository;
}
public TSetting Get<TSetting>(IIndexerBase indexer) where TSetting : IIndexerSetting, new()
{
var json = _indexerRepository.Get(indexer.Name).Settings;
return JsonConvert.DeserializeObject<TSetting>(json);
}
}
}