2012-02-05 06:34:36 +00:00
|
|
|
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
|
|
|
|
using Ninject;
|
|
|
|
using Ninject.Web.Mvc;
|
2012-04-22 22:18:28 +00:00
|
|
|
using NzbDrone.Services.Service.Datastore;
|
2012-03-30 01:35:35 +00:00
|
|
|
using NzbDrone.Services.Service.Migrations;
|
2012-02-17 22:04:22 +00:00
|
|
|
using Services.PetaPoco;
|
2012-02-05 06:34:36 +00:00
|
|
|
|
|
|
|
[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();
|
2012-03-30 01:35:35 +00:00
|
|
|
MigrationsHelper.Run(Connection.GetConnectionString);
|
2012-03-01 05:39:15 +00:00
|
|
|
kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb());
|
2012-03-30 01:35:35 +00:00
|
|
|
|
2012-02-05 06:34:36 +00:00
|
|
|
return kernel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|