Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added usage and customization sections

  • Loading branch information...
commit fe96311346845322c068958ccaae47133f034677 1 parent 6543e5d
@thecodejunkie thecodejunkie authored
Showing with 48 additions and 0 deletions.
  1. +48 −0 readme.md
View
48 readme.md
@@ -1,3 +1,51 @@
+A [bootstrapper](https://github.com/NancyFx/Nancy/wiki/Bootstrapper) implementation, for the [Nancy](http://nancyfx.org) framework, based on the Autofac inversion of control container.
+
+## Usage
+
+When Nancy detects that the `NinjectNancyBootstrapper` type is available in the AppDomain of your application, it will assume you want to use it, rather than the default one.
+
+The easiest way to get the latest version of `NinjectNancyBootstrapper` into your application is to install the `Nancy.Boostrappers.Ninject` nuget.
+
+### Customizing
+
+By inheriting from `NinjectNancyBootstrapper` you will gain access to the `IKernel` of the application and request containers and can perform what ever reqistations that your application requires.
+
+```c#
+public class Bootstrapper : NinjectNancyBootstrapper
+{
+ protected override void ApplicationStartup(IKernel container, IPipelines pipelines)
+ {
+ // No registrations should be performed in here, however you may
+ // resolve things that are needed during application startup.
+ }
+
+ protected override void ConfigureApplicationContainer(IKernel existingContainer)
+ {
+ // Perform registation that should have an application lifetime
+ }
+
+ protected override void ConfigureRequestContainer(IKernel container, NancyContext context)
+ {
+ // Perform registrations that should have a request lifetime
+ }
+
+ protected override void RequestStartup(IKernel container, IPipelines pipelines, NancyContext context)
+ {
+ // No registrations should be performed in here, however you may
+ // resolve things that are needed during request startup.
+ }
+}
+```
+
+You can also override the `GetApplicationContainer` method and return a pre-existing container instance, instead of having Nancy create one for you. This is useful if Nancy is co-existing with another application and you want them to share a single container.
+
+```c#
+protected override IKernel GetApplicationContainer()
+{
+ // Return application container instance
+}
+```
+
## Contributors
* [Andreas Håkansson](http://github.com/thecodejunkie)
Please sign in to comment.
Something went wrong with that request. Please try again.