fixed schema support for indexers

This commit is contained in:
kay.one 2013-09-22 17:27:00 -07:00 committed by kayone
commit 4f9b745e70
3 changed files with 29 additions and 21 deletions

View file

@ -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)