From 0b179a608661780b91174b52fcc4b582c4d5a452 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sat, 21 Sep 2013 00:09:26 -0700 Subject: [PATCH] starting to move indexers to generic provider. --- .../ThingiProvider/ProviderBaseFixture.cs | 22 ++++++------- ...2_move_notification_to_generic_provider.cs | 6 ++-- NzbDrone.Core/Datastore/TableMapping.cs | 1 - NzbDrone.Core/Indexers/IIndexerSetting.cs | 9 ----- NzbDrone.Core/Indexers/IndexerBase.cs | 3 +- NzbDrone.Core/Indexers/IndexerDefinition.cs | 6 ++-- NzbDrone.Core/Indexers/IndexerService.cs | 7 ++-- .../Indexers/IndexerSettingProvider.cs | 31 ----------------- .../Indexers/IndexerSettingUpdatedEvent.cs | 5 +-- NzbDrone.Core/Indexers/IndexerWithSetting.cs | 3 +- NzbDrone.Core/Indexers/Newznab/Newznab.cs | 4 +-- .../Indexers/Newznab/NewznabSettings.cs | 3 +- NzbDrone.Core/Indexers/NullSetting.cs | 14 -------- .../Indexers/Omgwtfnzbs/OmgwtfnzbsSettings.cs | 3 +- .../Notifications/Email/EmailSettings.cs | 6 ++++ .../Notifications/Growl/GrowlSettings.cs | 6 ++++ .../Notifications/NotificationDefinition.cs | 2 +- .../Notifications/NotificationService.cs | 6 ++-- .../NotifyMyAndroidSettings.cs | 6 ++++ .../Notifications/Plex/PlexClientSettings.cs | 6 ++++ .../Notifications/Plex/PlexServerSettings.cs | 6 ++++ .../Notifications/Prowl/ProwlSettings.cs | 6 ++++ .../PushBullet/PushBulletSettings.cs | 6 ++++ .../Pushover/PushoverSettings.cs | 6 ++++ .../Notifications/Xbmc/XbmcSettings.cs | 6 ++++ NzbDrone.Core/NzbDrone.Core.csproj | 3 -- NzbDrone.Core/ThingiProvider/ProviderBase.cs | 33 ++++++++++++------- 27 files changed, 111 insertions(+), 104 deletions(-) delete mode 100644 NzbDrone.Core/Indexers/IIndexerSetting.cs delete mode 100644 NzbDrone.Core/Indexers/IndexerSettingProvider.cs delete mode 100644 NzbDrone.Core/Indexers/NullSetting.cs diff --git a/NzbDrone.Core.Test/ThingiProvider/ProviderBaseFixture.cs b/NzbDrone.Core.Test/ThingiProvider/ProviderBaseFixture.cs index 2d9cb0f9e..3ecfa62ac 100644 --- a/NzbDrone.Core.Test/ThingiProvider/ProviderBaseFixture.cs +++ b/NzbDrone.Core.Test/ThingiProvider/ProviderBaseFixture.cs @@ -1,31 +1,31 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.Notifications; -using NzbDrone.Core.Notifications.Email; +using NzbDrone.Core.Indexers; +using NzbDrone.Core.Indexers.Newznab; using NzbDrone.Core.Test.Framework; using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Test.ThingiProvider { - public class ProviderRepositoryFixture : DbTest + public class ProviderRepositoryFixture : DbTest { [Test] public void should_read_write_download_provider() { - var model = Builder.CreateNew().BuildNew(); - var emailSettings = Builder.CreateNew().Build(); - model.Settings = emailSettings; + var model = Builder.CreateNew().BuildNew(); + var newznabSettings = Builder.CreateNew().Build(); + model.Settings = newznabSettings; Subject.Insert(model); var storedProvider = Subject.Single(); - - storedProvider.Settings.Should().BeOfType(); - var storedSetting = (EmailSettings) storedProvider.Settings; - - storedSetting.ShouldHave().AllProperties().EqualTo(emailSettings); + storedProvider.Settings.Should().BeOfType(); + + var storedSetting = (NewznabSettings)storedProvider.Settings; + + storedSetting.ShouldHave().AllProperties().EqualTo(newznabSettings); } } } \ No newline at end of file diff --git a/NzbDrone.Core/Datastore/Migration/022_move_notification_to_generic_provider.cs b/NzbDrone.Core/Datastore/Migration/022_move_notification_to_generic_provider.cs index d0210438f..2b5182419 100644 --- a/NzbDrone.Core/Datastore/Migration/022_move_notification_to_generic_provider.cs +++ b/NzbDrone.Core/Datastore/Migration/022_move_notification_to_generic_provider.cs @@ -8,11 +8,11 @@ using NzbDrone.Core.Datastore.Migration.Framework; namespace NzbDrone.Core.Datastore.Migration { [Migration(22)] - public class move_notification_to_generic_provider : NzbDroneMigrationBase + public class move_indexer_to_generic_provider : NzbDroneMigrationBase { protected override void MainDbUpgrade() { - Alter.Table("Notifications").AddColumn("ConfigContract").AsString().Nullable(); + Alter.Table("Indexers").AddColumn("ConfigContract").AsString().Nullable(); //Execute.WithConnection(ConvertSeasons); } @@ -54,7 +54,7 @@ namespace NzbDrone.Core.Datastore.Migration using (IDbCommand updateCmd = conn.CreateCommand()) { - var text = String.Format("UPDATE Series SET Seasons = '{0}' WHERE Id = {1}", seasons.ToJson() , seriesId); + var text = String.Format("UPDATE Series SET Seasons = '{0}' WHERE Id = {1}", seasons.ToJson(), seriesId); updateCmd.Transaction = tran; updateCmd.CommandText = text; diff --git a/NzbDrone.Core/Datastore/TableMapping.cs b/NzbDrone.Core/Datastore/TableMapping.cs index 3feda3e13..bade3c2d6 100644 --- a/NzbDrone.Core/Datastore/TableMapping.cs +++ b/NzbDrone.Core/Datastore/TableMapping.cs @@ -36,7 +36,6 @@ namespace NzbDrone.Core.Datastore Mapper.Entity().RegisterModel("Indexers"); Mapper.Entity().RegisterModel("ScheduledTasks"); Mapper.Entity().RegisterModel("Notifications"); - Mapper.Entity().RegisterModel("Notifications"); Mapper.Entity().RegisterModel("SceneMappings"); diff --git a/NzbDrone.Core/Indexers/IIndexerSetting.cs b/NzbDrone.Core/Indexers/IIndexerSetting.cs deleted file mode 100644 index 4f9cf16de..000000000 --- a/NzbDrone.Core/Indexers/IIndexerSetting.cs +++ /dev/null @@ -1,9 +0,0 @@ -using FluentValidation.Results; - -namespace NzbDrone.Core.Indexers -{ - public interface IIndexerSetting - { - ValidationResult Validate(); - } -} diff --git a/NzbDrone.Core/Indexers/IndexerBase.cs b/NzbDrone.Core/Indexers/IndexerBase.cs index 6f544a2be..28a2d1d46 100644 --- a/NzbDrone.Core/Indexers/IndexerBase.cs +++ b/NzbDrone.Core/Indexers/IndexerBase.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Indexers { @@ -22,7 +23,7 @@ namespace NzbDrone.Core.Indexers Name = Name, Enable = EnableByDefault, Implementation = GetType().Name, - Settings = String.Empty + Settings = NullSetting.Instance }; } } diff --git a/NzbDrone.Core/Indexers/IndexerDefinition.cs b/NzbDrone.Core/Indexers/IndexerDefinition.cs index a061052e7..02238e0e9 100644 --- a/NzbDrone.Core/Indexers/IndexerDefinition.cs +++ b/NzbDrone.Core/Indexers/IndexerDefinition.cs @@ -1,13 +1,11 @@ using System; using NzbDrone.Core.Datastore; +using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Indexers { - public class IndexerDefinition : ModelBase + public class IndexerDefinition : ProviderDefinition { public Boolean Enable { get; set; } - public String Name { get; set; } - public String Settings { get; set; } - public String Implementation { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/IndexerService.cs b/NzbDrone.Core/Indexers/IndexerService.cs index e1b49c2dd..5d42c2a9d 100644 --- a/NzbDrone.Core/Indexers/IndexerService.cs +++ b/NzbDrone.Core/Indexers/IndexerService.cs @@ -7,6 +7,7 @@ using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers.Newznab; using NzbDrone.Core.Lifecycle; using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.ThingiProvider; using Omu.ValueInjecter; namespace NzbDrone.Core.Indexers @@ -16,7 +17,7 @@ namespace NzbDrone.Core.Indexers public int Id { get; set; } public string Name { get; set; } public bool Enable { get; set; } - public IIndexerSetting Settings { get; set; } + public IProviderConfig Settings { get; set; } public IIndexer Instance { get; set; } public string Implementation { get; set; } } @@ -107,7 +108,7 @@ namespace NzbDrone.Core.Indexers Name = indexer.Name, Enable = indexer.Enable, Implementation = indexer.Implementation, - Settings = indexer.Settings.ToJson() + Settings = indexer.Settings }; var instance = ToIndexer(definition).Instance; @@ -123,7 +124,7 @@ namespace NzbDrone.Core.Indexers { var definition = _indexerRepository.Get(indexer.Id); definition.InjectFrom(indexer); - definition.Settings = indexer.Settings.ToJson(); + definition.Settings = indexer.Settings; _indexerRepository.Update(definition); return indexer; diff --git a/NzbDrone.Core/Indexers/IndexerSettingProvider.cs b/NzbDrone.Core/Indexers/IndexerSettingProvider.cs deleted file mode 100644 index ab7da9e58..000000000 --- a/NzbDrone.Core/Indexers/IndexerSettingProvider.cs +++ /dev/null @@ -1,31 +0,0 @@ -using NzbDrone.Common.Serializer; - -namespace NzbDrone.Core.Indexers -{ - public interface IProviderIndexerSetting - { - TSetting Get(IIndexer indexer) where TSetting : IIndexerSetting, new(); - } - - public class IndexerSettingProvider : IProviderIndexerSetting - { - private readonly IIndexerRepository _indexerRepository; - - public IndexerSettingProvider(IIndexerRepository indexerRepository) - { - _indexerRepository = indexerRepository; - } - - public TSetting Get(IIndexer indexer) where TSetting : IIndexerSetting, new() - { - var indexerDef = _indexerRepository.Find(indexer.Name); - - if (indexerDef == null || string.IsNullOrWhiteSpace(indexerDef.Settings)) - { - return new TSetting(); - } - - return Json.Deserialize(indexerDef.Settings); - } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/IndexerSettingUpdatedEvent.cs b/NzbDrone.Core/Indexers/IndexerSettingUpdatedEvent.cs index 8b3edc513..783948b2e 100644 --- a/NzbDrone.Core/Indexers/IndexerSettingUpdatedEvent.cs +++ b/NzbDrone.Core/Indexers/IndexerSettingUpdatedEvent.cs @@ -1,13 +1,14 @@ using NzbDrone.Common.Messaging; +using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Indexers { public class IndexerSettingUpdatedEvent : IEvent { public string IndexerName { get; private set; } - public IIndexerSetting IndexerSetting { get; private set; } + public IProviderConfig IndexerSetting { get; private set; } - public IndexerSettingUpdatedEvent(string indexerName, IIndexerSetting indexerSetting) + public IndexerSettingUpdatedEvent(string indexerName, IProviderConfig indexerSetting) { IndexerName = indexerName; IndexerSetting = indexerSetting; diff --git a/NzbDrone.Core/Indexers/IndexerWithSetting.cs b/NzbDrone.Core/Indexers/IndexerWithSetting.cs index 78db54932..ecba9f7a9 100644 --- a/NzbDrone.Core/Indexers/IndexerWithSetting.cs +++ b/NzbDrone.Core/Indexers/IndexerWithSetting.cs @@ -1,8 +1,9 @@ using NzbDrone.Common.Serializer; +using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Indexers { - public abstract class IndexerWithSetting : IndexerBase where TSetting : class, IIndexerSetting, new() + public abstract class IndexerWithSetting : IndexerBase where TSetting : class, IProviderConfig, new() { public TSetting Settings { get; set; } diff --git a/NzbDrone.Core/Indexers/Newznab/Newznab.cs b/NzbDrone.Core/Indexers/Newznab/Newznab.cs index 8a13d2282..e2daf28d6 100644 --- a/NzbDrone.Core/Indexers/Newznab/Newznab.cs +++ b/NzbDrone.Core/Indexers/Newznab/Newznab.cs @@ -51,7 +51,7 @@ namespace NzbDrone.Core.Indexers.Newznab } } - private string GetSettings(string url, List categories) + private NewznabSettings GetSettings(string url, List categories) { var settings = new NewznabSettings { Url = url }; @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Indexers.Newznab settings.Categories = categories; } - return settings.ToJson(); + return settings; } public override IEnumerable RecentFeed diff --git a/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs b/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs index c83623ace..5f05ba96d 100644 --- a/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs +++ b/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using FluentValidation; using FluentValidation.Results; using NzbDrone.Core.Annotations; +using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; namespace NzbDrone.Core.Indexers.Newznab @@ -16,7 +17,7 @@ namespace NzbDrone.Core.Indexers.Newznab } - public class NewznabSettings : IIndexerSetting + public class NewznabSettings : IProviderConfig { private static readonly NewznabSettingsValidator Validator = new NewznabSettingsValidator(); diff --git a/NzbDrone.Core/Indexers/NullSetting.cs b/NzbDrone.Core/Indexers/NullSetting.cs deleted file mode 100644 index a7013335a..000000000 --- a/NzbDrone.Core/Indexers/NullSetting.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentValidation.Results; - -namespace NzbDrone.Core.Indexers -{ - public class NullSetting : IIndexerSetting - { - public static readonly NullSetting Instance = new NullSetting(); - - public ValidationResult Validate() - { - return new ValidationResult(); - } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsSettings.cs b/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsSettings.cs index 778b3a48e..900055608 100644 --- a/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsSettings.cs +++ b/NzbDrone.Core/Indexers/Omgwtfnzbs/OmgwtfnzbsSettings.cs @@ -2,6 +2,7 @@ using FluentValidation; using FluentValidation.Results; using NzbDrone.Core.Annotations; +using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Indexers.Omgwtfnzbs { @@ -14,7 +15,7 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs } } - public class OmgwtfnzbsSettings : IIndexerSetting + public class OmgwtfnzbsSettings : IProviderConfig { private static readonly OmgwtfnzbsSettingsValidator Validator = new OmgwtfnzbsSettingsValidator(); diff --git a/NzbDrone.Core/Notifications/Email/EmailSettings.cs b/NzbDrone.Core/Notifications/Email/EmailSettings.cs index 1d678dae9..42aa725cd 100644 --- a/NzbDrone.Core/Notifications/Email/EmailSettings.cs +++ b/NzbDrone.Core/Notifications/Email/EmailSettings.cs @@ -1,4 +1,5 @@ using System; +using FluentValidation.Results; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; @@ -39,5 +40,10 @@ namespace NzbDrone.Core.Notifications.Email return !string.IsNullOrWhiteSpace(Server) && Port > 0 && !string.IsNullOrWhiteSpace(From) && !string.IsNullOrWhiteSpace(To); } } + + public ValidationResult Validate() + { + throw new NotImplementedException(); + } } } diff --git a/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs b/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs index 75c3de74a..dd049268d 100644 --- a/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs +++ b/NzbDrone.Core/Notifications/Growl/GrowlSettings.cs @@ -1,4 +1,5 @@ using System; +using FluentValidation.Results; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; @@ -27,5 +28,10 @@ namespace NzbDrone.Core.Notifications.Growl return !string.IsNullOrWhiteSpace(Host) && !string.IsNullOrWhiteSpace(Password) && Port > 0; } } + + public ValidationResult Validate() + { + throw new NotImplementedException(); + } } } diff --git a/NzbDrone.Core/Notifications/NotificationDefinition.cs b/NzbDrone.Core/Notifications/NotificationDefinition.cs index 15f274dfc..41fc64509 100644 --- a/NzbDrone.Core/Notifications/NotificationDefinition.cs +++ b/NzbDrone.Core/Notifications/NotificationDefinition.cs @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Notifications } - public class NotificationProviderModel : Provider + public class NotificationProviderModel : ProviderDefinition { public Boolean OnGrab { get; set; } public Boolean OnDownload { get; set; } diff --git a/NzbDrone.Core/Notifications/NotificationService.cs b/NzbDrone.Core/Notifications/NotificationService.cs index 3febb84e0..458c80d65 100644 --- a/NzbDrone.Core/Notifications/NotificationService.cs +++ b/NzbDrone.Core/Notifications/NotificationService.cs @@ -19,7 +19,7 @@ namespace NzbDrone.Core.Notifications Notification Get(int id); List Schema(); Notification Create(Notification notification); - Notification Update(Notification notification); + void Update(Notification notification); void Delete(int id); } @@ -94,15 +94,13 @@ namespace NzbDrone.Core.Notifications return notification; } - public Notification Update(Notification notification) + public void Update(Notification notification) { var definition = _notificationRepository.Get(notification.Id); definition.InjectFrom(notification); definition.Settings = notification.Settings.ToJson(); _notificationRepository.Update(definition); - - return notification; } public void Delete(int id) diff --git a/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroidSettings.cs b/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroidSettings.cs index f9a4da283..48c8c6fc6 100644 --- a/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroidSettings.cs +++ b/NzbDrone.Core/Notifications/NotifyMyAndroid/NotifyMyAndroidSettings.cs @@ -1,4 +1,5 @@ using System; +using FluentValidation.Results; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; @@ -19,5 +20,10 @@ namespace NzbDrone.Core.Notifications.NotifyMyAndroid return !String.IsNullOrWhiteSpace(ApiKey) && Priority != null & Priority >= -1 && Priority <= 2; } } + + public ValidationResult Validate() + { + throw new NotImplementedException(); + } } } diff --git a/NzbDrone.Core/Notifications/Plex/PlexClientSettings.cs b/NzbDrone.Core/Notifications/Plex/PlexClientSettings.cs index 95c9a3291..a0d762406 100644 --- a/NzbDrone.Core/Notifications/Plex/PlexClientSettings.cs +++ b/NzbDrone.Core/Notifications/Plex/PlexClientSettings.cs @@ -1,4 +1,5 @@ using System; +using FluentValidation.Results; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; @@ -30,5 +31,10 @@ namespace NzbDrone.Core.Notifications.Plex return !string.IsNullOrWhiteSpace(Host); } } + + public ValidationResult Validate() + { + throw new NotImplementedException(); + } } } diff --git a/NzbDrone.Core/Notifications/Plex/PlexServerSettings.cs b/NzbDrone.Core/Notifications/Plex/PlexServerSettings.cs index 9f4e3cc5f..ed410767b 100644 --- a/NzbDrone.Core/Notifications/Plex/PlexServerSettings.cs +++ b/NzbDrone.Core/Notifications/Plex/PlexServerSettings.cs @@ -1,4 +1,5 @@ using System; +using FluentValidation.Results; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; @@ -27,5 +28,10 @@ namespace NzbDrone.Core.Notifications.Plex return !string.IsNullOrWhiteSpace(Host); } } + + public ValidationResult Validate() + { + throw new NotImplementedException(); + } } } diff --git a/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs b/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs index 1b6db74cc..66b574179 100644 --- a/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs +++ b/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs @@ -1,4 +1,5 @@ using System; +using FluentValidation.Results; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; @@ -19,5 +20,10 @@ namespace NzbDrone.Core.Notifications.Prowl return !string.IsNullOrWhiteSpace(ApiKey) && Priority != null & Priority >= -2 && Priority <= 2; } } + + public ValidationResult Validate() + { + throw new NotImplementedException(); + } } } diff --git a/NzbDrone.Core/Notifications/PushBullet/PushBulletSettings.cs b/NzbDrone.Core/Notifications/PushBullet/PushBulletSettings.cs index cf34b3718..1886991d8 100644 --- a/NzbDrone.Core/Notifications/PushBullet/PushBulletSettings.cs +++ b/NzbDrone.Core/Notifications/PushBullet/PushBulletSettings.cs @@ -1,4 +1,5 @@ using System; +using FluentValidation.Results; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; @@ -19,5 +20,10 @@ namespace NzbDrone.Core.Notifications.PushBullet return !String.IsNullOrWhiteSpace(ApiKey) && DeviceId > 0; } } + + public ValidationResult Validate() + { + throw new NotImplementedException(); + } } } diff --git a/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs b/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs index 4a42baac9..ca4c332c7 100644 --- a/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs +++ b/NzbDrone.Core/Notifications/Pushover/PushoverSettings.cs @@ -1,4 +1,5 @@ using System; +using FluentValidation.Results; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; @@ -19,5 +20,10 @@ namespace NzbDrone.Core.Notifications.Pushover return !string.IsNullOrWhiteSpace(UserKey) && Priority != null & Priority >= -1 && Priority <= 2; } } + + public ValidationResult Validate() + { + throw new NotImplementedException(); + } } } diff --git a/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs b/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs index 26e114d30..2c0569c89 100644 --- a/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs +++ b/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs @@ -1,5 +1,6 @@ using System; using System.ComponentModel; +using FluentValidation.Results; using Newtonsoft.Json; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; @@ -52,5 +53,10 @@ namespace NzbDrone.Core.Notifications.Xbmc return !string.IsNullOrWhiteSpace(Host) && Port > 0; } } + + public ValidationResult Validate() + { + throw new NotImplementedException(); + } } } diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 049d2cb4c..f8d3c3b7c 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -246,7 +246,6 @@ - @@ -343,13 +342,11 @@ - - diff --git a/NzbDrone.Core/ThingiProvider/ProviderBase.cs b/NzbDrone.Core/ThingiProvider/ProviderBase.cs index bf24434d2..f91577aa9 100644 --- a/NzbDrone.Core/ThingiProvider/ProviderBase.cs +++ b/NzbDrone.Core/ThingiProvider/ProviderBase.cs @@ -1,36 +1,35 @@  +using FluentValidation.Results; using NzbDrone.Core.Datastore; +using NzbDrone.Core.Indexers; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Notifications; namespace NzbDrone.Core.ThingiProvider { - - - public class DownloadProviderRepository : BasicRepository + public class NotificationProviderRepository : BasicRepository { - public DownloadProviderRepository(IDatabase database, IEventAggregator eventAggregator) + public NotificationProviderRepository(IDatabase database, IEventAggregator eventAggregator) : base(database, eventAggregator) { } } - public class NotificationProviderRepository : BasicRepository + public class IndexerProviderRepository : BasicRepository { - public NotificationProviderRepository(IDatabase database, IEventAggregator eventAggregator) + public IndexerProviderRepository(IDatabase database, IEventAggregator eventAggregator) : base(database, eventAggregator) { } } - public class DownloadProviderModel : Provider + public abstract class ProviderBase { - + public ProviderDefinition Definition { get; set; } } - - public abstract class Provider : ModelBase + public abstract class ProviderDefinition : ModelBase { public string Name { get; set; } public string Implementation { get; set; } @@ -44,7 +43,7 @@ namespace NzbDrone.Core.ThingiProvider } set { - + } } @@ -53,6 +52,16 @@ namespace NzbDrone.Core.ThingiProvider public interface IProviderConfig { - bool IsValid { get; } + ValidationResult Validate(); + } + + public class NullSetting : IProviderConfig + { + public static readonly NullSetting Instance = new NullSetting(); + + public ValidationResult Validate() + { + return new ValidationResult(); + } } } \ No newline at end of file