indexers implementation is now separated from settings/definition

so we can have multiple newznab definitions.
This commit is contained in:
Keivan Beigi 2013-05-01 18:59:09 -07:00
commit 96990eabb3
28 changed files with 270 additions and 345 deletions

View file

@ -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;
}
}
}