cleaned up ThingiProvider

pull/4/head
kayone 11 years ago
parent 7b14d09976
commit c9f5cb0257

@ -128,7 +128,7 @@ namespace NzbDrone.Core.Indexers
}
catch (ApiKeyException)
{
_logger.Warn("Invalid API Key for {0} {1}", indexer.Name, url);
_logger.Warn("Invalid API Key for {0} {1}", indexer, url);
}
catch (Exception feedEx)
{

@ -422,7 +422,13 @@
<Compile Include="Rest\RestSharpExtensions.cs" />
<Compile Include="Rest\RestException.cs" />
<Compile Include="SeriesStats\SeriesStatisticsService.cs" />
<Compile Include="ThingiProvider\ProviderService.cs" />
<Compile Include="ThingiProvider\IProviderConfig.cs" />
<Compile Include="ThingiProvider\IProviderFactory.cs" />
<Compile Include="ThingiProvider\IProviderRepository.cs" />
<Compile Include="ThingiProvider\NullConfig.cs" />
<Compile Include="ThingiProvider\ProviderDefinition.cs" />
<Compile Include="ThingiProvider\ProviderRepository.cs" />
<Compile Include="ThingiProvider\ProviderFactory.cs" />
<Compile Include="Tv\EpisodeService.cs" />
<Compile Include="Tv\Events\EpisodeInfoDeletedEvent.cs" />
<Compile Include="Tv\Events\EpisodeInfoUpdatedEvent.cs" />
@ -621,4 +627,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

@ -13,7 +13,7 @@
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>5000</DefaultTestTimeout>
<UseBuildConfiguration>Debug</UseBuildConfiguration>
<UseBuildConfiguration>RELEASE</UseBuildConfiguration>
<UseBuildPlatform>x86</UseBuildPlatform>
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>x86</UseCPUArchitecture>

@ -1,33 +1,9 @@

using System;
using System.Collections.Generic;
using FluentValidation.Results;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.ThingiProvider
{
public interface IProviderRepository<TProvider> : IBasicRepository<TProvider> where TProvider : ModelBase, new()
{
TProvider GetByName(string name);
}
public class ProviderRepository<TProviderDefinition> : BasicRepository<TProviderDefinition>, IProviderRepository<TProviderDefinition>
where TProviderDefinition : ModelBase,
new()
{
protected ProviderRepository(IDatabase database, IEventAggregator eventAggregator)
: base(database, eventAggregator)
{
}
public TProviderDefinition GetByName(string name)
{
throw new NotImplementedException();
}
}
public interface IProvider
{
Type ConfigContract { get; }
@ -35,45 +11,4 @@ namespace NzbDrone.Core.ThingiProvider
IEnumerable<ProviderDefinition> DefaultDefinitions { get; }
ProviderDefinition Definition { get; set; }
}
public abstract class ProviderDefinition : ModelBase
{
private IProviderConfig _settings;
public string Name { get; set; }
public string Implementation { get; set; }
public bool Enable { get; set; }
public string ConfigContract { get; set; }
public IProviderConfig Settings
{
get
{
return _settings;
}
set
{
_settings = value;
if (value != null)
{
ConfigContract = value.GetType().Name;
}
}
}
}
public interface IProviderConfig
{
ValidationResult Validate();
}
public class NullConfig : IProviderConfig
{
public static readonly NullConfig Instance = new NullConfig();
public ValidationResult Validate()
{
return new ValidationResult();
}
}
}

@ -0,0 +1,9 @@
using FluentValidation.Results;
namespace NzbDrone.Core.ThingiProvider
{
public interface IProviderConfig
{
ValidationResult Validate();
}
}

@ -0,0 +1,17 @@
using System.Collections.Generic;
namespace NzbDrone.Core.ThingiProvider
{
public interface IProviderFactory<TProvider, TProviderDefinition>
where TProviderDefinition : ProviderDefinition, new()
where TProvider : IProvider
{
List<TProviderDefinition> All();
List<TProvider> GetAvailableProviders();
TProviderDefinition Get(int id);
TProviderDefinition Create(TProviderDefinition indexer);
void Update(TProviderDefinition indexer);
void Delete(int id);
List<TProviderDefinition> Templates();
}
}

@ -0,0 +1,8 @@
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.ThingiProvider
{
public interface IProviderRepository<TProvider> : IBasicRepository<TProvider> where TProvider : ModelBase, new()
{
}
}

@ -0,0 +1,14 @@
using FluentValidation.Results;
namespace NzbDrone.Core.ThingiProvider
{
public class NullConfig : IProviderConfig
{
public static readonly NullConfig Instance = new NullConfig();
public ValidationResult Validate()
{
return new ValidationResult();
}
}
}

@ -0,0 +1,30 @@
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.ThingiProvider
{
public abstract class ProviderDefinition : ModelBase
{
private IProviderConfig _settings;
public string Name { get; set; }
public string Implementation { get; set; }
public bool Enable { get; set; }
public string ConfigContract { get; set; }
public IProviderConfig Settings
{
get
{
return _settings;
}
set
{
_settings = value;
if (value != null)
{
ConfigContract = value.GetType().Name;
}
}
}
}
}

@ -2,25 +2,11 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common.Reflection;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.ThingiProvider
{
public interface IProviderFactory<TProvider, TProviderDefinition>
where TProviderDefinition : ProviderDefinition, new()
where TProvider : IProvider
{
List<TProviderDefinition> All();
List<TProvider> GetAvailableProviders();
TProviderDefinition Get(int id);
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>
where TProviderDefinition : ProviderDefinition, new()
where TProvider : IProvider

@ -0,0 +1,16 @@
using System;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.ThingiProvider
{
public class ProviderRepository<TProviderDefinition> : BasicRepository<TProviderDefinition>, IProviderRepository<TProviderDefinition>
where TProviderDefinition : ModelBase,
new()
{
protected ProviderRepository(IDatabase database, IEventAggregator eventAggregator)
: base(database, eventAggregator)
{
}
}
}
Loading…
Cancel
Save