Moved over to using Ninject

pull/470/head
tidusjar 8 years ago
parent 36bbf3375c
commit 0e1f1ecd40

@ -32,43 +32,46 @@ 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.Session;
using Nancy.TinyIoc;
using PlexRequests.Api;
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;
using PlexRequests.Store.Models;
using PlexRequests.Store.Repository;
using PlexRequests.UI.Helpers;
using Nancy.Json;
using PlexRequests.Helpers.Analytics;
using PlexRequests.Services.Jobs;
using PlexRequests.UI.Jobs;
using Quartz;
using Quartz.Impl;
using Quartz.Spi;
using Ninject;
namespace PlexRequests.UI
{
public class Bootstrapper : DefaultNancyBootstrapper
public class Bootstrapper : NinjectNancyBootstrapper
{
// The bootstrapper enables you to reconfigure the composition of the framework,
// by overriding the various methods and properties.
// For more information https://github.com/NancyFx/Nancy/wiki/Bootstrapper
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
public Bootstrapper(IKernel kernel)
{
_kernel = kernel;
}
private IKernel _kernel;
protected override IKernel GetApplicationContainer()
{
_kernel.Load<FactoryModule>();
return _kernel;
}
protected override void ApplicationStartup(IKernel container, IPipelines pipelines)
{
ConfigureContainer(container);
@ -87,7 +90,7 @@ namespace PlexRequests.UI
var formsAuthConfiguration = new FormsAuthenticationConfiguration
{
RedirectUrl = redirect,
UserMapper = container.Resolve<IUserMapper>()
UserMapper = container.Get<IUserMapper>()
};
FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
@ -115,40 +118,40 @@ namespace PlexRequests.UI
protected override DiagnosticsConfiguration DiagnosticsConfiguration => new DiagnosticsConfiguration { Password = @"password" };
private void SubscribeAllObservers(TinyIoCContainer container)
private void SubscribeAllObservers(IKernel container)
{
var notificationService = container.Resolve<INotificationService>();
var notificationService = container.Get<INotificationService>();
var emailSettingsService = container.Resolve<ISettingsService<EmailNotificationSettings>>();
var emailSettingsService = container.Get<ISettingsService<EmailNotificationSettings>>();
var emailSettings = emailSettingsService.GetSettings();
if (emailSettings.Enabled)
{
notificationService.Subscribe(new EmailMessageNotification(emailSettingsService));
}
var pushbulletService = container.Resolve<ISettingsService<PushbulletNotificationSettings>>();
var pushbulletService = container.Get<ISettingsService<PushbulletNotificationSettings>>();
var pushbulletSettings = pushbulletService.GetSettings();
if (pushbulletSettings.Enabled)
{
notificationService.Subscribe(new PushbulletNotification(container.Resolve<IPushbulletApi>(), pushbulletService));
notificationService.Subscribe(new PushbulletNotification(container.Get<IPushbulletApi>(), pushbulletService));
}
var pushoverService = container.Resolve<ISettingsService<PushoverNotificationSettings>>();
var pushoverService = container.Get<ISettingsService<PushoverNotificationSettings>>();
var pushoverSettings = pushoverService.GetSettings();
if (pushoverSettings.Enabled)
{
notificationService.Subscribe(new PushoverNotification(container.Resolve<IPushoverApi>(), pushoverService));
notificationService.Subscribe(new PushoverNotification(container.Get<IPushoverApi>(), pushoverService));
}
var slackService = container.Resolve<ISettingsService<SlackNotificationSettings>>();
var slackService = container.Get<ISettingsService<SlackNotificationSettings>>();
var slackSettings = slackService.GetSettings();
if (slackSettings.Enabled)
{
notificationService.Subscribe(new SlackNotification(container.Resolve<ISlackApi>(), slackService));
notificationService.Subscribe(new SlackNotification(container.Get<ISlackApi>(), slackService));
}
}
protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
protected override void RequestStartup(IKernel container, IPipelines pipelines, NancyContext context)
{
//CORS Enable
pipelines.AfterRequest.AddItemToEndOfPipeline((ctx) =>
@ -161,68 +164,9 @@ namespace PlexRequests.UI
base.RequestStartup(container, pipelines, context);
}
private void ConfigureContainer(TinyIoCContainer container)
private void ConfigureContainer(IKernel container)
{
container.Register<ICacheProvider, MemoryCacheProvider>().AsSingleton();
container.Register<ISqliteConfiguration, DbConfiguration>(new DbConfiguration(new SqliteFactory()));
container.Register<IRepository<UsersModel>, UserRepository<UsersModel>>();
container.Register<IUserMapper, UserMapper>();
container.Register<ICustomUserMapper, UserMapper>();
container.Register<ISettingsService<EmailNotificationSettings>, SettingsServiceV2<EmailNotificationSettings>>();
container.Register<ISettingsService<PushbulletNotificationSettings>, SettingsServiceV2<PushbulletNotificationSettings>>();
container.Register<ISettingsService<PushoverNotificationSettings>, SettingsServiceV2<PushoverNotificationSettings>>();
container.Register<ISettingsService<SlackNotificationSettings>, SettingsServiceV2<SlackNotificationSettings>>();
container.Register<ISettingsService<ScheduledJobsSettings>, SettingsServiceV2<ScheduledJobsSettings>>();
// Notification Service
container.Register<INotificationService, NotificationService>().AsSingleton();
// Settings
container.Register<ISettingsService<PlexRequestSettings>, SettingsServiceV2<PlexRequestSettings>>();
container.Register<ISettingsService<CouchPotatoSettings>, SettingsServiceV2<CouchPotatoSettings>>();
container.Register<ISettingsService<AuthenticationSettings>, SettingsServiceV2<AuthenticationSettings>>();
container.Register<ISettingsService<PlexSettings>, SettingsServiceV2<PlexSettings>>();
container.Register<ISettingsService<SonarrSettings>, SettingsServiceV2<SonarrSettings>>();
container.Register<ISettingsService<SickRageSettings>, SettingsServiceV2<SickRageSettings>>();
container.Register<ISettingsService<HeadphonesSettings>, SettingsServiceV2<HeadphonesSettings>>();
container.Register<ISettingsService<LogSettings>, SettingsServiceV2<LogSettings>>();
container.Register<ISettingsService<LandingPageSettings>, SettingsServiceV2<LandingPageSettings>>();
// Repo's
container.Register<IRepository<LogEntity>, GenericRepository<LogEntity>>();
container.Register<IRepository<UsersToNotify>, GenericRepository<UsersToNotify>>();
container.Register<IRepository<ScheduledJobs>, GenericRepository<ScheduledJobs>>();
container.Register<IRepository<IssueBlobs>, GenericRepository<IssueBlobs>>();
container.Register<IRepository<RequestLimit>, GenericRepository<RequestLimit>>();
container.Register<IRepository<PlexUsers>, GenericRepository<PlexUsers>>();
container.Register<IRequestService, JsonRequestModelRequestService>();
container.Register<IIssueService, IssueJsonService>();
container.Register<ISettingsRepository, SettingsJsonRepository>();
container.Register<IJobRecord, JobRecord>();
// Services
container.Register<IAvailabilityChecker, PlexAvailabilityChecker>();
container.Register<ICouchPotatoCacher, CouchPotatoCacher>();
container.Register<ISonarrCacher, SonarrCacher>();
container.Register<ISickRageCacher, SickRageCacher>();
container.Register<IJobFactory, CustomJobFactory>();
container.Register<IAnalytics, Analytics>();
container.Register<ISchedulerFactory, StdSchedulerFactory>();
container.Register<IJobScheduler, Scheduler>();
// Api
container.Register<ICouchPotatoApi, CouchPotatoApi>();
container.Register<IPushbulletApi, PushbulletApi>();
container.Register<IPushoverApi, PushoverApi>();
container.Register<ISickRageApi, SickrageApi>();
container.Register<ISonarrApi, SonarrApi>();
container.Register<IPlexApi, PlexApi>();
container.Register<IMusicBrainzApi, MusicBrainzApi>();
container.Register<IHeadphonesApi, HeadphonesApi>();
container.Register<ISlackApi, SlackApi>();
var loc = ServiceLocator.Instance;
loc.SetContainer(container);
}

@ -28,6 +28,8 @@ using System;
using Nancy.TinyIoc;
using Ninject;
namespace PlexRequests.UI.Helpers
{
public class ServiceLocator : IServiceLocator
@ -37,21 +39,21 @@ namespace PlexRequests.UI.Helpers
Singleton = new ServiceLocator();
}
private static ServiceLocator Singleton { get; }
private TinyIoCContainer Container { get; set; }
private IKernel Container { get; set; }
public static ServiceLocator Instance => Singleton;
public void SetContainer(TinyIoCContainer con)
public void SetContainer(IKernel con)
{
Container = con;
}
public T Resolve<T>() where T : class
{
return Container?.Resolve<T>();
return Container?.Get<T>();
}
public object Resolve(Type type)
{
return Container.Resolve(type);
return Container.Get(type);
}
}

@ -0,0 +1,50 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: ApiModule.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 Ninject.Modules;
using PlexRequests.Api;
using PlexRequests.Api.Interfaces;
namespace PlexRequests.UI.NinjectModules
{
public class ApiModule : NinjectModule
{
public override void Load()
{
Bind<ICouchPotatoApi>().To<CouchPotatoApi>();
Bind<IPushbulletApi>().To<PushbulletApi>();
Bind<IPushoverApi>().To<PushoverApi>();
Bind<ISickRageApi>().To<SickrageApi>();
Bind<ISonarrApi>().To<SonarrApi>();
Bind<IPlexApi>().To<PlexApi>();
Bind<IMusicBrainzApi>().To<MusicBrainzApi>();
Bind<IHeadphonesApi>().To<HeadphonesApi>();
Bind<ISlackApi>().To<SlackApi>();
Bind<IApiRequest>().To<ApiRequest>();
}
}
}

@ -0,0 +1,55 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: ConfigurationModule.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 Mono.Data.Sqlite;
using Nancy;
using Nancy.Authentication.Forms;
using Ninject.Modules;
using PlexRequests.Core;
using PlexRequests.Helpers;
using PlexRequests.Services.Interfaces;
using PlexRequests.Services.Notification;
using PlexRequests.Store;
namespace PlexRequests.UI.NinjectModules
{
public class ConfigurationModule : NinjectModule
{
public override void Load()
{
Bind<ICacheProvider>().To<MemoryCacheProvider>().InSingletonScope();
Bind<ISqliteConfiguration>().To<DbConfiguration>().WithConstructorArgument("provider", new SqliteFactory());
Bind<IUserMapper>().To<UserMapper>();
Bind<ICustomUserMapper>().To<UserMapper>();
Bind<INotificationService>().To<NotificationService>().InSingletonScope();
}
}
}

@ -0,0 +1,48 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: DependancyResolver.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 System;
using System.Linq;
using System.Reflection;
using Ninject.Modules;
namespace PlexRequests.UI.NinjectModules
{
public class DependancyResolver
{
public NinjectModule[] GetModules()
{
var path = Assembly.GetAssembly(typeof(SettingServiceModule)).Location;
var result = Assembly.LoadFrom(path).GetTypes()
.Where(a =>
a.IsClass &&
a.BaseType == typeof(NinjectModule));
return result.Select(r => Activator.CreateInstance(r) as NinjectModule).ToArray();
}
}
}

@ -0,0 +1,52 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: RepositoryModule.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 Ninject.Modules;
using PlexRequests.Core;
using PlexRequests.Services.Interfaces;
using PlexRequests.Services.Jobs;
using PlexRequests.Store;
using PlexRequests.Store.Repository;
namespace PlexRequests.UI.NinjectModules
{
public class RepositoryModule : NinjectModule
{
public override void Load()
{
Bind<IRepository<UsersModel>>().To<UserRepository<UsersModel>>();
Bind(typeof(IRepository<>)).To(typeof(GenericRepository<>));
Bind<IRequestService>().To<JsonRequestModelRequestService>();
Bind<IRequestRepository>().To<RequestJsonRepository>();
Bind<IIssueService>().To<IssueJsonService>();
Bind<ISettingsRepository>().To<SettingsJsonRepository>();
Bind<IJobRecord>().To<JobRecord>();
}
}
}

@ -0,0 +1,55 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: ServicesModule.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 Ninject.Modules;
using PlexRequests.Helpers.Analytics;
using PlexRequests.Services.Interfaces;
using PlexRequests.Services.Jobs;
using PlexRequests.UI.Jobs;
using Quartz;
using Quartz.Impl;
using Quartz.Spi;
namespace PlexRequests.UI.NinjectModules
{
public class ServicesModule : NinjectModule
{
public override void Load()
{
Bind<IAvailabilityChecker>().To<PlexAvailabilityChecker>();
Bind<ICouchPotatoCacher>().To<CouchPotatoCacher>();
Bind<ISonarrCacher>().To<SonarrCacher>();
Bind<ISickRageCacher>().To<SickRageCacher>();
Bind<IJobFactory>().To<CustomJobFactory>();
Bind<IAnalytics>().To<Analytics>();
Bind<ISchedulerFactory>().To<StdSchedulerFactory>();
Bind<IJobScheduler>().To<Scheduler>();
}
}
}

@ -0,0 +1,40 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: SettingServiceModule.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 Ninject.Modules;
using PlexRequests.Core;
namespace PlexRequests.UI.NinjectModules
{
public class SettingServiceModule : NinjectModule
{
public override void Load()
{
Bind(typeof(ISettingsService<>)).To(typeof(SettingsServiceV2<>));
}
}
}

@ -57,6 +57,10 @@
<HintPath>..\packages\Nancy.1.4.3\lib\net40\Nancy.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nancy.Bootstrappers.Ninject, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nancy.Bootstrappers.Ninject.1.4.1\lib\net40\Nancy.Bootstrappers.Ninject.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nancy.Metadata.Modules, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nancy.Metadata.Modules.1.4.1\lib\net40\Nancy.Metadata.Modules.dll</HintPath>
<Private>True</Private>
@ -65,6 +69,14 @@
<HintPath>..\packages\Nancy.Swagger.0.1.0-alpha3\lib\net40\Nancy.Swagger.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Ninject, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<HintPath>..\packages\Ninject.3.0.1.10\lib\net45-full\Ninject.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Ninject.Extensions.ChildKernel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<HintPath>..\packages\Ninject.Extensions.ChildKernel.3.0.0.5\lib\net45-full\Ninject.Extensions.ChildKernel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.3.4\lib\net45\NLog.dll</HintPath>
<Private>True</Private>
@ -202,6 +214,12 @@
<Compile Include="Modules\LandingPageModule.cs" />
<Compile Include="Modules\PlexUsersModule.cs" />
<Compile Include="Modules\UpdateCheckerModule.cs" />
<Compile Include="NinjectModules\ApiModule.cs" />
<Compile Include="NinjectModules\ConfigurationModule.cs" />
<Compile Include="NinjectModules\DependancyResolver.cs" />
<Compile Include="NinjectModules\RepositoryModule.cs" />
<Compile Include="NinjectModules\ServicesModule.cs" />
<Compile Include="NinjectModules\SettingServiceModule.cs" />
<Compile Include="Resources\UI.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>

@ -28,12 +28,17 @@ using System;
using Nancy.TinyIoc;
using Ninject;
using Ninject.Modules;
using Ninject.Planning.Bindings.Resolvers;
using NLog;
using Owin;
using PlexRequests.UI.Helpers;
using PlexRequests.UI.Jobs;
using PlexRequests.UI.NinjectModules;
namespace PlexRequests.UI
{
@ -45,7 +50,28 @@ namespace PlexRequests.UI
{
try
{
app.UseNancy();
var resolver = new DependancyResolver();
var modules = resolver.GetModules();
var kernel = new StandardKernel(modules);
//kernel.Bind(x => x.FromThisAssembly()
// .SelectAllClasses()
// .InheritedFromAny(
// new[]
// {
// typeof(IRequestHandler<,>),
// typeof(IAsyncRequestHandler<,>),
// })
// .BindDefaultInterfaces());
//kernel.Components.Add<IBindingResolver, ContravariantBindingResolver>();
//kernel.Bind(scan => scan.FromAssemblyContaining<IMediator>().SelectAllClasses().BindDefaultInterface());
//kernel.Bind(scan => scan.FromAssemblyContaining<LandingPageCommand>().SelectAllInterfaces().BindAllInterfaces());
//kernel.Bind<SingleInstanceFactory>().ToMethod(ctx => t => ctx.Kernel.Get(t));
//kernel.Bind<MultiInstanceFactory>().ToMethod(ctx => t => ctx.Kernel.GetAll(t));
app.UseNancy(options => options.Bootstrapper = new Bootstrapper(kernel));
var scheduler = new Scheduler();
scheduler.StartScheduler();
}

@ -19,6 +19,7 @@
<package id="Nancy" version="1.4.3" targetFramework="net45" />
<package id="Nancy.Authentication.Basic" version="1.4.1" targetFramework="net45" />
<package id="Nancy.Authentication.Forms" version="1.4.1" targetFramework="net45" />
<package id="Nancy.Bootstrappers.Ninject" version="1.4.1" targetFramework="net45" />
<package id="Nancy.Hosting.Self" version="1.4.1" targetFramework="net45" />
<package id="Nancy.Metadata.Modules" version="1.4.1" targetFramework="net45" />
<package id="Nancy.Owin" version="1.4.1" targetFramework="net45" />
@ -27,6 +28,8 @@
<package id="Nancy.Validation.FluentValidation" version="1.4.1" targetFramework="net45" />
<package id="Nancy.Viewengines.Razor" version="1.4.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net45" />
<package id="Ninject" version="3.0.1.10" targetFramework="net45" />
<package id="Ninject.Extensions.ChildKernel" version="3.0.0.5" targetFramework="net45" />
<package id="NLog" version="4.3.4" targetFramework="net45" />
<package id="NLog.Config" version="4.2.3" targetFramework="net45" />
<package id="NLog.Schema" version="4.0.0" targetFramework="net45" />

Loading…
Cancel
Save