You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.1 KiB
66 lines
2.1 KiB
12 years ago
|
using NzbDrone.Services.Service.Datastore;
|
||
|
using NzbDrone.Services.Service.Migrations;
|
||
|
using Services.PetaPoco;
|
||
14 years ago
|
|
||
12 years ago
|
[assembly: WebActivator.PreApplicationStartMethod(typeof(NzbDrone.Services.Service.App_Start.NinjectWebCommon), "Start")]
|
||
|
[assembly: WebActivator.ApplicationShutdownMethodAttribute(typeof(NzbDrone.Services.Service.App_Start.NinjectWebCommon), "Stop")]
|
||
|
|
||
|
namespace NzbDrone.Services.Service.App_Start
|
||
14 years ago
|
{
|
||
12 years ago
|
using System;
|
||
|
using System.Web;
|
||
|
|
||
14 years ago
|
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
|
||
12 years ago
|
|
||
14 years ago
|
using Ninject;
|
||
12 years ago
|
using Ninject.Web.Common;
|
||
14 years ago
|
|
||
12 years ago
|
public static class NinjectWebCommon
|
||
14 years ago
|
{
|
||
|
private static readonly Bootstrapper bootstrapper = new Bootstrapper();
|
||
|
|
||
|
/// <summary>
|
||
|
/// Starts the application
|
||
|
/// </summary>
|
||
|
public static void Start()
|
||
|
{
|
||
12 years ago
|
DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
|
||
|
DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
|
||
14 years ago
|
bootstrapper.Initialize(CreateKernel);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Stops the application.
|
||
|
/// </summary>
|
||
|
public static void Stop()
|
||
|
{
|
||
|
bootstrapper.ShutDown();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Creates the kernel that will manage your application.
|
||
|
/// </summary>
|
||
|
/// <returns>The created kernel.</returns>
|
||
|
private static IKernel CreateKernel()
|
||
|
{
|
||
|
var kernel = new StandardKernel();
|
||
12 years ago
|
kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
|
||
|
kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
|
||
|
|
||
|
MigrationsHelper.Run(Connection.GetConnectionString);
|
||
|
kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb());
|
||
|
|
||
14 years ago
|
RegisterServices(kernel);
|
||
|
return kernel;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Load your modules or register your services here!
|
||
|
/// </summary>
|
||
|
/// <param name="kernel">The kernel.</param>
|
||
|
private static void RegisterServices(IKernel kernel)
|
||
|
{
|
||
|
}
|
||
|
}
|
||
|
}
|