You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/NzbDrone.Core/Notifications/NotificationSettingsProvide...

32 lines
1.0 KiB

using NzbDrone.Common.Serializer;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Notifications
{
public interface INotificationSettingsProvider
{
TSetting Get<TSetting>(INotification indexer) where TSetting : IProviderConfig, new();
}
public class NotificationSettingsProvider : INotificationSettingsProvider
{
private readonly INotificationRepository _notificationRepository;
public NotificationSettingsProvider(INotificationRepository notificationRepository)
{
_notificationRepository = notificationRepository;
}
public TSetting Get<TSetting>(INotification indexer) where TSetting : IProviderConfig, new()
{
var indexerDef = _notificationRepository.Find(indexer.Name);
if (indexerDef == null || string.IsNullOrWhiteSpace(indexerDef.Settings))
{
return new TSetting();
}
return Json.Deserialize<TSetting>(indexerDef.Settings);
}
}
}