mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-29 11:16:19 +00:00
25 lines
No EOL
763 B
C#
25 lines
No EOL
763 B
C#
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);
|
|
}
|
|
}
|
|
} |