2013-09-21 00:18:11 +00:00
|
|
|
|
|
2013-09-22 05:20:26 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2013-09-21 07:09:26 +00:00
|
|
|
|
using FluentValidation.Results;
|
2013-09-21 00:18:11 +00:00
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.ThingiProvider
|
|
|
|
|
{
|
2013-09-22 05:20:26 +00:00
|
|
|
|
public interface IProviderRepository<TProvider> : IBasicRepository<TProvider> where TProvider : ModelBase, new()
|
2013-09-21 00:18:11 +00:00
|
|
|
|
{
|
2013-09-22 05:20:26 +00:00
|
|
|
|
TProvider GetByName(string name);
|
2013-09-21 00:18:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-09-22 05:20:26 +00:00
|
|
|
|
public class ProviderRepository<TProviderDefinition> : BasicRepository<TProviderDefinition>, IProviderRepository<TProviderDefinition>
|
|
|
|
|
where TProviderDefinition : ModelBase,
|
|
|
|
|
new()
|
2013-09-21 06:39:26 +00:00
|
|
|
|
{
|
2013-09-22 05:20:26 +00:00
|
|
|
|
protected ProviderRepository(IDatabase database, IEventAggregator eventAggregator)
|
2013-09-21 06:39:26 +00:00
|
|
|
|
: base(database, eventAggregator)
|
|
|
|
|
{
|
|
|
|
|
}
|
2013-09-22 05:20:26 +00:00
|
|
|
|
|
|
|
|
|
public TProviderDefinition GetByName(string name)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2013-09-21 00:18:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-22 05:20:26 +00:00
|
|
|
|
public interface IProvider
|
2013-09-21 00:18:11 +00:00
|
|
|
|
{
|
2013-09-22 20:00:29 +00:00
|
|
|
|
Type ConfigContract { get; }
|
2013-09-22 05:20:26 +00:00
|
|
|
|
|
|
|
|
|
IEnumerable<ProviderDefinition> DefaultDefinitions { get; }
|
|
|
|
|
ProviderDefinition Definition { get; set; }
|
2013-09-21 00:18:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-21 07:09:26 +00:00
|
|
|
|
public abstract class ProviderDefinition : ModelBase
|
2013-09-21 00:18:11 +00:00
|
|
|
|
{
|
2013-09-22 23:40:36 +00:00
|
|
|
|
private IProviderConfig _settings;
|
2013-09-21 06:39:26 +00:00
|
|
|
|
public string Name { get; set; }
|
2013-09-21 00:18:11 +00:00
|
|
|
|
public string Implementation { get; set; }
|
2013-09-22 05:20:26 +00:00
|
|
|
|
public bool Enable { get; set; }
|
2013-09-21 00:18:11 +00:00
|
|
|
|
|
2013-09-22 23:40:36 +00:00
|
|
|
|
public string ConfigContract { get; set; }
|
|
|
|
|
|
|
|
|
|
public IProviderConfig Settings
|
2013-09-21 06:39:26 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2013-09-22 23:40:36 +00:00
|
|
|
|
return _settings;
|
2013-09-21 06:39:26 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2013-09-22 23:40:36 +00:00
|
|
|
|
_settings = value;
|
|
|
|
|
if (value != null)
|
|
|
|
|
{
|
|
|
|
|
ConfigContract = value.GetType().Name;
|
|
|
|
|
}
|
2013-09-21 06:39:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-21 00:18:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-21 06:39:26 +00:00
|
|
|
|
public interface IProviderConfig
|
2013-09-21 00:18:11 +00:00
|
|
|
|
{
|
2013-09-21 07:09:26 +00:00
|
|
|
|
ValidationResult Validate();
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-22 20:00:29 +00:00
|
|
|
|
public class NullConfig : IProviderConfig
|
2013-09-21 07:09:26 +00:00
|
|
|
|
{
|
2013-09-22 20:00:29 +00:00
|
|
|
|
public static readonly NullConfig Instance = new NullConfig();
|
2013-09-21 07:09:26 +00:00
|
|
|
|
|
|
|
|
|
public ValidationResult Validate()
|
|
|
|
|
{
|
|
|
|
|
return new ValidationResult();
|
|
|
|
|
}
|
2013-09-21 00:18:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|