mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 05:23:31 -07:00
indexers implementation is now separated from settings/definition
so we can have multiple newznab definitions.
This commit is contained in:
parent
50fd2f77b1
commit
96990eabb3
28 changed files with 270 additions and 345 deletions
|
@ -1,38 +1,16 @@
|
|||
using System;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
public abstract class IndexerWithSetting<TSetting> :
|
||||
Indexer,
|
||||
IHandle<IndexerSettingUpdatedEvent> where TSetting : IIndexerSetting, new()
|
||||
public abstract class IndexerWithSetting<TSetting> : IndexerBase where TSetting : class, IIndexerSetting, new()
|
||||
{
|
||||
protected IndexerWithSetting(IProviderIndexerSetting settingProvider)
|
||||
{
|
||||
Settings = settingProvider.Get<TSetting>(this);
|
||||
}
|
||||
|
||||
public override bool IsConfigured
|
||||
{
|
||||
get { return Settings.IsValid; }
|
||||
}
|
||||
|
||||
public override bool EnabledByDefault
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public TSetting Settings { get; private set; }
|
||||
|
||||
public void Handle(IndexerSettingUpdatedEvent message)
|
||||
public TSetting ImportSettingsFromJson(string json)
|
||||
{
|
||||
if (message.IndexerName.Equals(Name, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
Settings = (TSetting)message.IndexerSetting;
|
||||
}
|
||||
Settings = new JsonSerializer().Deserialize<TSetting>(json) ?? new TSetting();
|
||||
|
||||
return Settings;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue