Small refactorings

This commit is contained in:
Jamie.Rees 2016-12-16 09:28:48 +00:00
parent 1067b9afd7
commit 83bb1b58e7
7 changed files with 41 additions and 46 deletions

View file

@ -31,13 +31,11 @@ using System.Net;
using Mono.Data.Sqlite;
using Nancy;
using Nancy.Authentication.Forms;
using Nancy.Bootstrapper;
using Nancy.Bootstrappers.Ninject;
using Nancy.Conventions;
using Nancy.Cryptography;
using Nancy.Diagnostics;
using Nancy.Hosting.Self;
using Nancy.Session;
using PlexRequests.Api.Interfaces;
@ -105,9 +103,6 @@ namespace PlexRequests.UI
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback +=
(sender, certificate, chain, sslPolicyErrors) => true;
SubscribeAllObservers(container);
}
#if DEBUG
@ -142,39 +137,6 @@ namespace PlexRequests.UI
protected override DiagnosticsConfiguration DiagnosticsConfiguration => new DiagnosticsConfiguration { Password = @"password" };
private void SubscribeAllObservers(IKernel container)
{
var notificationService = container.Get<INotificationService>();
var emailSettingsService = container.Get<ISettingsService<EmailNotificationSettings>>();
var emailSettings = emailSettingsService.GetSettings();
if (emailSettings.Enabled)
{
notificationService.Subscribe(new EmailMessageNotification(emailSettingsService));
}
var pushbulletService = container.Get<ISettingsService<PushbulletNotificationSettings>>();
var pushbulletSettings = pushbulletService.GetSettings();
if (pushbulletSettings.Enabled)
{
notificationService.Subscribe(new PushbulletNotification(container.Get<IPushbulletApi>(), pushbulletService));
}
var pushoverService = container.Get<ISettingsService<PushoverNotificationSettings>>();
var pushoverSettings = pushoverService.GetSettings();
if (pushoverSettings.Enabled)
{
notificationService.Subscribe(new PushoverNotification(container.Get<IPushoverApi>(), pushoverService));
}
var slackService = container.Get<ISettingsService<SlackNotificationSettings>>();
var slackSettings = slackService.GetSettings();
if (slackSettings.Enabled)
{
notificationService.Subscribe(new SlackNotification(container.Get<ISlackApi>(), slackService));
}
}
protected override void RequestStartup(IKernel container, IPipelines pipelines, NancyContext context)
{
//CORS Enable