Radarr/src/NzbDrone.Core/Notifications/NotificationFactory.cs

39 lines
1.4 KiB
C#
Raw Normal View History

using System.Collections.Generic;
2013-10-13 02:46:36 +00:00
using System.Linq;
using NLog;
2013-10-13 02:46:36 +00:00
using NzbDrone.Common.Composition;
2014-02-26 05:40:47 +00:00
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Notifications
{
public interface INotificationFactory : IProviderFactory<INotification, NotificationDefinition>
{
2013-10-13 02:46:36 +00:00
List<INotification> OnGrabEnabled();
List<INotification> OnDownloadEnabled();
List<INotification> OnUpgradeEnabled();
}
public class NotificationFactory : ProviderFactory<INotification, NotificationDefinition>, INotificationFactory
{
2014-02-26 05:40:47 +00:00
public NotificationFactory(INotificationRepository providerRepository, IEnumerable<INotification> providers, IContainer container, IEventAggregator eventAggregator, Logger logger)
: base(providerRepository, providers, container, eventAggregator, logger)
{
2013-10-13 02:46:36 +00:00
}
2013-10-13 02:46:36 +00:00
public List<INotification> OnGrabEnabled()
{
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnGrab).ToList();
}
public List<INotification> OnDownloadEnabled()
{
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnDownload).ToList();
}
public List<INotification> OnUpgradeEnabled()
{
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnUpgrade).ToList();
}
}
}