-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from jpsingleton/refactor
DI Refactor
- Loading branch information
Showing
41 changed files
with
488 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Huxley.ldbServiceReference; | ||
|
||
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(Huxley.App_Start.NinjectWebCommon), "Start")] | ||
[assembly: WebActivatorEx.ApplicationShutdownMethodAttribute(typeof(Huxley.App_Start.NinjectWebCommon), "Stop")] | ||
|
||
namespace Huxley.App_Start { | ||
using System; | ||
using System.Web; | ||
using Microsoft.Web.Infrastructure.DynamicModuleHelper; | ||
using Ninject; | ||
using Ninject.Web.Common; | ||
|
||
public static class NinjectWebCommon { | ||
private static readonly Bootstrapper Bootstrapper = new Bootstrapper(); | ||
|
||
/// <summary> | ||
/// Starts the application | ||
/// </summary> | ||
public static void Start() { | ||
DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule)); | ||
DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule)); | ||
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(); | ||
try { | ||
kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel); | ||
kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>(); | ||
kernel.Bind<ILdbClient>().To<LdbClient>().InRequestScope(); | ||
kernel.Bind<LDBServiceSoapClient>().To<LDBServiceSoapClient>().InRequestScope(); | ||
return kernel; | ||
} catch { | ||
kernel.Dispose(); | ||
throw; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.