Lidarr/NzbDrone.Core/ThingiProvider/IProvider.cs

79 lines
2.0 KiB
C#
Raw Normal View History

2013-09-21 00:18:11 +00:00

2013-09-22 05:20:26 +00:00
using System;
using System.Collections.Generic;
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-22 05:20:26 +00:00
protected ProviderRepository(IDatabase database, IEventAggregator eventAggregator)
: 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
}
public abstract class ProviderDefinition : ModelBase
2013-09-21 00:18:11 +00:00
{
2013-09-22 23:40:36 +00:00
private IProviderConfig _settings;
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
{
get
{
2013-09-22 23:40:36 +00:00
return _settings;
}
set
{
2013-09-22 23:40:36 +00:00
_settings = value;
if (value != null)
{
ConfigContract = value.GetType().Name;
}
}
}
2013-09-21 00:18:11 +00:00
}
public interface IProviderConfig
2013-09-21 00:18:11 +00:00
{
ValidationResult Validate();
}
2013-09-22 20:00:29 +00:00
public class NullConfig : IProviderConfig
{
2013-09-22 20:00:29 +00:00
public static readonly NullConfig Instance = new NullConfig();
public ValidationResult Validate()
{
return new ValidationResult();
}
2013-09-21 00:18:11 +00:00
}
}