|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.Reflection;
|
|
|
|
|
using NzbDrone.Core.Lifecycle;
|
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
|
|
|
|
|
@ -17,6 +18,7 @@ namespace NzbDrone.Core.ThingiProvider
|
|
|
|
|
TProviderDefinition Create(TProviderDefinition indexer);
|
|
|
|
|
void Update(TProviderDefinition indexer);
|
|
|
|
|
void Delete(int id);
|
|
|
|
|
List<TProviderDefinition> Templates();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract class ProviderFactory<TProvider, TProviderDefinition> : IProviderFactory<TProvider, TProviderDefinition>, IHandle<ApplicationStartedEvent>
|
|
|
|
@ -40,6 +42,16 @@ namespace NzbDrone.Core.ThingiProvider
|
|
|
|
|
return _providerRepository.All().ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<TProviderDefinition> Templates()
|
|
|
|
|
{
|
|
|
|
|
return _providers.Select(p => new TProviderDefinition()
|
|
|
|
|
{
|
|
|
|
|
ConfigContract = p.ConfigContract.Name,
|
|
|
|
|
Implementation = p.GetType().Name,
|
|
|
|
|
Settings = (IProviderConfig)Activator.CreateInstance(ReflectionExtensions.CoreAssembly.FindTypeByName(p.ConfigContract.Name))
|
|
|
|
|
}).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<TProvider> GetAvailableProviders()
|
|
|
|
|
{
|
|
|
|
|
return All().Where(c => c.Enable && c.Settings.Validate().IsValid)
|
|
|
|
|