Permalink
Browse files

Implemented GetDiagnostics

  • Loading branch information...
1 parent 768ca71 commit 9886615839c431a260c6e9c0133eb53915ba73ca @thecodejunkie thecodejunkie committed Aug 22, 2012
Showing with 149 additions and 139 deletions.
  1. +1 −1 dependencies/Nancy
  2. +148 −138 src/Nancy.Bootstrappers.Ninject/NinjectNancyBootstrapper.cs
Submodule Nancy updated 200 files
@@ -1,15 +1,25 @@
-namespace Nancy.Bootstrappers.Ninject
-{
- using System.Collections.Generic;
- using Nancy.Bootstrapper;
- using global::Ninject;
- using global::Ninject.Extensions.ChildKernel;
-
- /// <summary>
- /// Nancy bootstrapper for the Ninject container.
- /// </summary>
- public abstract class NinjectNancyBootstrapper : NancyBootstrapperWithRequestContainerBase<IKernel>
- {
+namespace Nancy.Bootstrappers.Ninject
+{
+ using System.Collections.Generic;
+ using Diagnostics;
+ using Nancy.Bootstrapper;
+ using global::Ninject;
+ using global::Ninject.Extensions.ChildKernel;
+
+ /// <summary>
+ /// Nancy bootstrapper for the Ninject container.
+ /// </summary>
+ public abstract class NinjectNancyBootstrapper : NancyBootstrapperWithRequestContainerBase<IKernel>
+ {
+ /// <summary>
+ /// Gets the diagnostics for intialisation
+ /// </summary>
+ /// <returns>IDiagnostics implementation</returns>
+ protected override IDiagnostics GetDiagnostics()
+ {
+ return this.ApplicationContainer.Get<IDiagnostics>();
+ }
+
/// <summary>
/// Gets all registered application startup tasks
/// </summary>
@@ -26,130 +36,130 @@ protected override IEnumerable<IApplicationStartup> GetApplicationStartupTasks()
protected override IEnumerable<IApplicationRegistrations> GetApplicationRegistrationTasks()
{
return this.ApplicationContainer.GetAll<IApplicationRegistrations>();
- }
-
- /// <summary>
- /// Get INancyEngine
- /// </summary>
- /// <returns>INancyEngine implementation</returns>
- protected override sealed INancyEngine GetEngineInternal()
- {
- return this.ApplicationContainer.Get<INancyEngine>();
- }
-
- /// <summary>
- /// Get the moduleKey generator
- /// </summary>
- /// <returns>IModuleKeyGenerator instance</returns>
- protected override sealed IModuleKeyGenerator GetModuleKeyGenerator()
- {
- return this.ApplicationContainer.Get<IModuleKeyGenerator>();
- }
-
- /// <summary>
- /// Create a default, unconfigured, container
- /// </summary>
- /// <returns>Container instance</returns>
- protected override IKernel GetApplicationContainer()
- {
- return new StandardKernel(new[] { new FactoryModule() });
- }
-
- /// <summary>
- /// Bind the bootstrapper's implemented types into the container.
- /// This is necessary so a user can pass in a populated container but not have
- /// to take the responsibility of registering things like INancyModuleCatalog manually.
- /// </summary>
- /// <param name="applicationContainer">Application container to register into</param>
- protected override sealed void RegisterBootstrapperTypes(IKernel applicationContainer)
- {
- applicationContainer.Bind<INancyModuleCatalog>().ToConstant(this);
- }
-
- /// <summary>
- /// Bind the default implementations of internally used types into the container as singletons
- /// </summary>
- /// <param name="container">Container to register into</param>
- /// <param name="typeRegistrations">Type registrations to register</param>
- protected override sealed void RegisterTypes(IKernel container, IEnumerable<TypeRegistration> typeRegistrations)
- {
- foreach (var typeRegistration in typeRegistrations)
- {
- container.Bind(typeRegistration.RegistrationType).To(typeRegistration.ImplementationType).InSingletonScope();
- }
- }
-
- /// <summary>
- /// Bind the various collections into the container as singletons to later be resolved
- /// by IEnumerable{Type} constructor dependencies.
- /// </summary>
- /// <param name="container">Container to register into</param>
- /// <param name="collectionTypeRegistrations">Collection type registrations to register</param>
- protected override sealed void RegisterCollectionTypes(IKernel container, IEnumerable<CollectionTypeRegistration> collectionTypeRegistrations)
- {
- foreach (var collectionTypeRegistration in collectionTypeRegistrations)
- {
- foreach (var implementationType in collectionTypeRegistration.ImplementationTypes)
- {
- container.Bind(collectionTypeRegistration.RegistrationType).To(implementationType).InSingletonScope();
- }
- }
- }
-
- /// <summary>
- /// Bind the given module types into the container
- /// </summary>
- /// <param name="container">Container to register into</param>
- /// <param name="moduleRegistrationTypes">NancyModule types</param>
- protected override sealed void RegisterRequestContainerModules(IKernel container, IEnumerable<ModuleRegistration> moduleRegistrationTypes)
- {
- foreach (var moduleRegistrationType in moduleRegistrationTypes)
- {
- container.Bind(typeof (NancyModule)).To(moduleRegistrationType.ModuleType).InSingletonScope().Named(moduleRegistrationType.ModuleKey);
- }
- }
-
- /// <summary>
- /// Bind the given instances into the container
- /// </summary>
- /// <param name="container">Container to register into</param>
- /// <param name="instanceRegistrations">Instance registration types</param>
- protected override void RegisterInstances(IKernel container, IEnumerable<InstanceRegistration> instanceRegistrations)
- {
- foreach (var instanceRegistration in instanceRegistrations)
- {
- container.Bind(instanceRegistration.RegistrationType).ToConstant(instanceRegistration.Implementation);
- }
- }
-
- /// <summary>
- /// Creates a per request child/nested container
- /// </summary>
- /// <returns>Request container instance</returns>
- protected override sealed IKernel CreateRequestContainer()
- {
- return new ChildKernel(this.ApplicationContainer);
- }
-
- /// <summary>
- /// Retrieve all module instances from the container
- /// </summary>
- /// <param name="container">Container to use</param>
- /// <returns>Collection of NancyModule instances</returns>
- protected override sealed IEnumerable<NancyModule> GetAllModules(IKernel container)
- {
- return container.GetAll<NancyModule>();
- }
-
- /// <summary>
- /// Retreive a specific module instance from the container by its key
- /// </summary>
- /// <param name="container">Container to use</param>
- /// <param name="moduleKey">Module key of the module</param>
- /// <returns>NancyModule instance</returns>
- protected override sealed NancyModule GetModuleByKey(IKernel container, string moduleKey)
- {
- return container.Get<NancyModule>(moduleKey);
- }
- }
+ }
+
+ /// <summary>
+ /// Get INancyEngine
+ /// </summary>
+ /// <returns>INancyEngine implementation</returns>
+ protected override sealed INancyEngine GetEngineInternal()
+ {
+ return this.ApplicationContainer.Get<INancyEngine>();
+ }
+
+ /// <summary>
+ /// Get the moduleKey generator
+ /// </summary>
+ /// <returns>IModuleKeyGenerator instance</returns>
+ protected override sealed IModuleKeyGenerator GetModuleKeyGenerator()
+ {
+ return this.ApplicationContainer.Get<IModuleKeyGenerator>();
+ }
+
+ /// <summary>
+ /// Create a default, unconfigured, container
+ /// </summary>
+ /// <returns>Container instance</returns>
+ protected override IKernel GetApplicationContainer()
+ {
+ return new StandardKernel(new[] { new FactoryModule() });
+ }
+
+ /// <summary>
+ /// Bind the bootstrapper's implemented types into the container.
+ /// This is necessary so a user can pass in a populated container but not have
+ /// to take the responsibility of registering things like INancyModuleCatalog manually.
+ /// </summary>
+ /// <param name="applicationContainer">Application container to register into</param>
+ protected override sealed void RegisterBootstrapperTypes(IKernel applicationContainer)
+ {
+ applicationContainer.Bind<INancyModuleCatalog>().ToConstant(this);
+ }
+
+ /// <summary>
+ /// Bind the default implementations of internally used types into the container as singletons
+ /// </summary>
+ /// <param name="container">Container to register into</param>
+ /// <param name="typeRegistrations">Type registrations to register</param>
+ protected override sealed void RegisterTypes(IKernel container, IEnumerable<TypeRegistration> typeRegistrations)
+ {
+ foreach (var typeRegistration in typeRegistrations)
+ {
+ container.Bind(typeRegistration.RegistrationType).To(typeRegistration.ImplementationType).InSingletonScope();
+ }
+ }
+
+ /// <summary>
+ /// Bind the various collections into the container as singletons to later be resolved
+ /// by IEnumerable{Type} constructor dependencies.
+ /// </summary>
+ /// <param name="container">Container to register into</param>
+ /// <param name="collectionTypeRegistrations">Collection type registrations to register</param>
+ protected override sealed void RegisterCollectionTypes(IKernel container, IEnumerable<CollectionTypeRegistration> collectionTypeRegistrations)
+ {
+ foreach (var collectionTypeRegistration in collectionTypeRegistrations)
+ {
+ foreach (var implementationType in collectionTypeRegistration.ImplementationTypes)
+ {
+ container.Bind(collectionTypeRegistration.RegistrationType).To(implementationType).InSingletonScope();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Bind the given module types into the container
+ /// </summary>
+ /// <param name="container">Container to register into</param>
+ /// <param name="moduleRegistrationTypes">NancyModule types</param>
+ protected override sealed void RegisterRequestContainerModules(IKernel container, IEnumerable<ModuleRegistration> moduleRegistrationTypes)
+ {
+ foreach (var moduleRegistrationType in moduleRegistrationTypes)
+ {
+ container.Bind(typeof (NancyModule)).To(moduleRegistrationType.ModuleType).InSingletonScope().Named(moduleRegistrationType.ModuleKey);
+ }
+ }
+
+ /// <summary>
+ /// Bind the given instances into the container
+ /// </summary>
+ /// <param name="container">Container to register into</param>
+ /// <param name="instanceRegistrations">Instance registration types</param>
+ protected override void RegisterInstances(IKernel container, IEnumerable<InstanceRegistration> instanceRegistrations)
+ {
+ foreach (var instanceRegistration in instanceRegistrations)
+ {
+ container.Bind(instanceRegistration.RegistrationType).ToConstant(instanceRegistration.Implementation);
+ }
+ }
+
+ /// <summary>
+ /// Creates a per request child/nested container
+ /// </summary>
+ /// <returns>Request container instance</returns>
+ protected override sealed IKernel CreateRequestContainer()
+ {
+ return new ChildKernel(this.ApplicationContainer);
+ }
+
+ /// <summary>
+ /// Retrieve all module instances from the container
+ /// </summary>
+ /// <param name="container">Container to use</param>
+ /// <returns>Collection of NancyModule instances</returns>
+ protected override sealed IEnumerable<NancyModule> GetAllModules(IKernel container)
+ {
+ return container.GetAll<NancyModule>();
+ }
+
+ /// <summary>
+ /// Retreive a specific module instance from the container by its key
+ /// </summary>
+ /// <param name="container">Container to use</param>
+ /// <param name="moduleKey">Module key of the module</param>
+ /// <returns>NancyModule instance</returns>
+ protected override sealed NancyModule GetModuleByKey(IKernel container, string moduleKey)
+ {
+ return container.Get<NancyModule>(moduleKey);
+ }
+ }
}

0 comments on commit 9886615

Please sign in to comment.