mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-29 19:26:06 +00:00
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
|
using NzbDrone.Services.Service.Datastore;
|
||
|
using PetaPoco;
|
||
|
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
|
||
|
using Ninject;
|
||
|
using Ninject.Web.Mvc;
|
||
|
|
||
|
[assembly: WebActivator.PreApplicationStartMethod(typeof(NzbDrone.Services.Service.App_Start.NinjectMVC3), "Start")]
|
||
|
[assembly: WebActivator.ApplicationShutdownMethodAttribute(typeof(NzbDrone.Services.Service.App_Start.NinjectMVC3), "Stop")]
|
||
|
|
||
|
namespace NzbDrone.Services.Service.App_Start
|
||
|
{
|
||
|
|
||
|
public static class NinjectMVC3
|
||
|
{
|
||
|
private static readonly Bootstrapper bootstrapper = new Bootstrapper();
|
||
|
|
||
|
public static void Start()
|
||
|
{
|
||
|
DynamicModuleUtility.RegisterModule(typeof(OnePerRequestModule));
|
||
|
DynamicModuleUtility.RegisterModule(typeof(HttpApplicationInitializationModule));
|
||
|
bootstrapper.Initialize(CreateKernel);
|
||
|
}
|
||
|
|
||
|
public static void Stop()
|
||
|
{
|
||
|
bootstrapper.ShutDown();
|
||
|
}
|
||
|
|
||
|
private static IKernel CreateKernel()
|
||
|
{
|
||
|
var kernel = new StandardKernel();
|
||
|
InitDb(kernel);
|
||
|
return kernel;
|
||
|
}
|
||
|
|
||
|
|
||
|
private static void InitDb(IKernel kernel)
|
||
|
{
|
||
|
var db = Connection.GetPetaPocoDb();
|
||
|
kernel.Bind<IDatabase>().ToConstant(db);
|
||
|
}
|
||
|
}
|
||
|
}
|