using System; using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Common.Composition; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Notifications { public interface INotificationFactory : IProviderFactory { List OnGrabEnabled(); List OnDownloadEnabled(); List OnUpgradeEnabled(); List OnRenameEnabled(); List OnMovieDeleteEnabled(); List OnMovieFileDeleteEnabled(); List OnHealthIssueEnabled(); } public class NotificationFactory : ProviderFactory, INotificationFactory { public NotificationFactory(INotificationRepository providerRepository, IEnumerable providers, IServiceProvider container, IEventAggregator eventAggregator, Logger logger) : base(providerRepository, providers, container, eventAggregator, logger) { } public List OnGrabEnabled() { return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnGrab).ToList(); } public List OnDownloadEnabled() { return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnDownload).ToList(); } public List OnUpgradeEnabled() { return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnUpgrade).ToList(); } public List OnRenameEnabled() { return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnRename).ToList(); } public List OnMovieDeleteEnabled() { return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnMovieDelete).ToList(); } public List OnMovieFileDeleteEnabled() { return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnMovieFileDelete).ToList(); } public List OnMovieFileDeleteForUpgradeEnabled() { return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnMovieFileDeleteForUpgrade).ToList(); } public List OnHealthIssueEnabled() { return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnHealthIssue).ToList(); } public override void SetProviderCharacteristics(INotification provider, NotificationDefinition definition) { base.SetProviderCharacteristics(provider, definition); definition.SupportsOnGrab = provider.SupportsOnGrab; definition.SupportsOnDownload = provider.SupportsOnDownload; definition.SupportsOnUpgrade = provider.SupportsOnUpgrade; definition.SupportsOnRename = provider.SupportsOnRename; definition.SupportsOnMovieDelete = provider.SupportsOnMovieDelete; definition.SupportsOnMovieFileDelete = provider.SupportsOnMovieFileDelete; definition.SupportsOnMovieFileDeleteForUpgrade = provider.SupportsOnMovieFileDeleteForUpgrade; definition.SupportsOnHealthIssue = provider.SupportsOnHealthIssue; } } }