1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 10:32:35 +01:00
Radarr/NzbDrone.Core/Providers/NotificationProvider.cs

52 lines
1.7 KiB
C#
Raw Normal View History

using System;
2010-10-12 04:49:27 +02:00
using System.Linq;
using System.Collections.Generic;
using NzbDrone.Core.Model.Notification;
namespace NzbDrone.Core.Providers
{
2011-04-09 01:48:47 +02:00
public class NotificationProvider
{
private readonly Dictionary<Guid, BasicNotification> _basicNotifications = new Dictionary<Guid, BasicNotification>();
2010-10-12 04:49:27 +02:00
private Dictionary<Guid, ProgressNotification> _progressNotification = new Dictionary<Guid, ProgressNotification>();
private readonly Object _lock = new object();
2011-04-09 01:55:23 +02:00
public virtual void Register(ProgressNotification notification)
{
_progressNotification.Add(notification.Id, notification);
}
2011-04-09 01:55:23 +02:00
public virtual void Register(BasicNotification notification)
{
_basicNotifications.Add(notification.Id, notification);
}
2011-04-09 01:55:23 +02:00
public virtual List<BasicNotification> BasicNotifications
{
get { return new List<BasicNotification>(_basicNotifications.Values); }
}
2011-04-09 01:55:23 +02:00
public virtual List<ProgressNotification> GetProgressNotifications
{
2010-11-06 01:43:13 +01:00
get
{
return new List<ProgressNotification>(_progressNotification.Values.Where(p => p.Status == ProgressNotificationStatus.InProgress));
}
}
2011-04-09 01:55:23 +02:00
public virtual void Dismiss(Guid notificationId)
{
lock (_lock)
{
if (_basicNotifications.ContainsKey(notificationId))
{
_basicNotifications.Remove(notificationId);
}
else if (_progressNotification.ContainsKey(notificationId))
{
_progressNotification.Remove(notificationId);
}
}
}
}
}