2013-04-10 23:44:48 +00:00
|
|
|
using System;
|
2013-04-24 01:56:00 +00:00
|
|
|
using NzbDrone.Common.Messaging;
|
2013-04-10 23:44:48 +00:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Indexers
|
|
|
|
{
|
|
|
|
public abstract class IndexerWithSetting<TSetting> :
|
|
|
|
Indexer,
|
|
|
|
IHandle<IndexerSettingUpdatedEvent> where TSetting : IIndexerSetting, new()
|
|
|
|
{
|
|
|
|
protected IndexerWithSetting(IProviderIndexerSetting settingProvider)
|
|
|
|
{
|
|
|
|
Settings = settingProvider.Get<TSetting>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool IsConfigured
|
|
|
|
{
|
|
|
|
get { return Settings.IsValid; }
|
|
|
|
}
|
|
|
|
|
2013-04-28 00:25:28 +00:00
|
|
|
public override bool EnabledByDefault
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public TSetting Settings { get; private set; }
|
2013-04-10 23:44:48 +00:00
|
|
|
|
|
|
|
public void Handle(IndexerSettingUpdatedEvent message)
|
|
|
|
{
|
|
|
|
if (message.IndexerName.Equals(Name, StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
{
|
|
|
|
Settings = (TSetting)message.IndexerSetting;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|