diff --git a/PlexRequests.UI/Bootstrapper.cs b/PlexRequests.UI/Bootstrapper.cs index 176404b02..a43f4c8f6 100644 --- a/PlexRequests.UI/Bootstrapper.cs +++ b/PlexRequests.UI/Bootstrapper.cs @@ -43,7 +43,6 @@ using PlexRequests.Api.Interfaces; using PlexRequests.Core; using PlexRequests.Core.SettingModels; using PlexRequests.Helpers; -using PlexRequests.Services; using PlexRequests.Services.Interfaces; using PlexRequests.Services.Notification; using PlexRequests.Store; @@ -147,7 +146,7 @@ namespace PlexRequests.UI notificationService.Subscribe(new SlackNotification(container.Resolve(), slackService)); } } - + protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context) { //CORS Enable @@ -168,31 +167,33 @@ namespace PlexRequests.UI container.Register, UserRepository>(); container.Register(); container.Register(); - container.Register, SettingsServiceV2>(); - container.Register, SettingsServiceV2>(); - container.Register, SettingsServiceV2>(); - container.Register, SettingsServiceV2>(); - container.Register, SettingsServiceV2>(); + + // Settings + container.RegisterSetting(); + container.RegisterSetting(); + container.RegisterSetting(); + container.RegisterSetting(); + container.RegisterSetting(); + container.RegisterSetting(); + container.RegisterSetting(); + container.RegisterSetting(); + container.RegisterSetting(); + container.RegisterSetting(); + container.RegisterSetting(); + container.RegisterSetting(); + container.RegisterSetting(); + container.RegisterSetting(); + + // Repository + container.RegisterRepo(); + container.RegisterRepo(); + container.RegisterRepo(); + container.RegisterRepo(); + // Notification Service container.Register().AsSingleton(); - // Settings - container.Register, SettingsServiceV2>(); - container.Register, SettingsServiceV2>(); - container.Register, SettingsServiceV2>(); - container.Register, SettingsServiceV2>(); - container.Register, SettingsServiceV2>(); - container.Register, SettingsServiceV2>(); - - container.Register, SettingsServiceV2>(); - container.Register, SettingsServiceV2>(); - container.Register, SettingsServiceV2>(); - - // Repo's - container.Register, GenericRepository>(); - container.Register, GenericRepository>(); - container.Register, GenericRepository>(); - container.Register, GenericRepository>(); + container.Register(); container.Register(); container.Register(); @@ -209,7 +210,7 @@ namespace PlexRequests.UI container.Register(); container.Register(); - + // Api container.Register(); container.Register(); diff --git a/PlexRequests.UI/Helpers/ContainerHelper.cs b/PlexRequests.UI/Helpers/ContainerHelper.cs new file mode 100644 index 000000000..85c4f7f92 --- /dev/null +++ b/PlexRequests.UI/Helpers/ContainerHelper.cs @@ -0,0 +1,48 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: ContainerHelper.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion +using Nancy.TinyIoc; + +using PlexRequests.Core; +using PlexRequests.Core.SettingModels; +using PlexRequests.Store; +using PlexRequests.Store.Repository; + +namespace PlexRequests.UI.Helpers +{ + public static class ContainerHelper + { + public static void RegisterSetting(this TinyIoCContainer container) where T : Settings, new() + { + container.Register, SettingsServiceV2>(); + } + + public static void RegisterRepo(this TinyIoCContainer container) where T : Entity, new() + { + container.Register, GenericRepository>(); + } + } +} \ No newline at end of file diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj index 99b5f8641..75290e3d1 100644 --- a/PlexRequests.UI/PlexRequests.UI.csproj +++ b/PlexRequests.UI/PlexRequests.UI.csproj @@ -159,6 +159,7 @@ +