Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Implemented GetDiagnostics #10

Merged
merged 1 commit into from

1 participant

@thecodejunkie

No description provided.

@thecodejunkie thecodejunkie merged commit 56dc857 into NancyFx:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 22, 2012
  1. @thecodejunkie
This page is out of date. Refresh to see the latest.
2  dependencies/Nancy
@@ -1 +1 @@
-Subproject commit c685a32fd71ee34571eca9480bc0abc554d6a4a1
+Subproject commit ba291fedf93b01b635cb35bcb492da893c659e55
View
286 src/Nancy.Bootstrappers.Ninject/NinjectNancyBootstrapper.cs
@@ -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);
+ }
+ }
}
Something went wrong with that request. Please try again.