Nancy bootstrapper for the Unity container.
C# Other
Latest commit 8c7605c Dec 27, 2016 @thecodejunkie thecodejunkie committed with khellang Fixed build.ps1 verbosity (#44)
Failed to load latest commit information.
src Delete nancy.bootstrappers.unity.nuspec Dec 22, 2016
Nancy.Bootstrappers.Unity.Next.sln Converted to project.json Mar 7, 2016
Nancy.Bootstrappers.Unity.sln Converted to project.json Mar 7, 2016
Nancy.Bootstrappers.Unity.sln.DotSettings Converted to project.json Mar 7, 2016
NuGet.config Updated to latest nancy and rc2 (#24) May 31, 2016
build.cake Massive clean up build.cake Dec 13, 2016
how_to_build.txt Added build.ps1/sh proxies Oct 24, 2016
license.txt Added project core files (rake, license, readme, nuspec, how_to_build) Jul 25, 2011

A bootstrapper implementation, for the Nancy framework, based on the Unity inversion of control container.


When Nancy detects that the UnityNancyBootstrapper 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 UnityNancyBootstrapper into your application is to install the Nancy.Bootstrappers.Unity nuget.


By inheriting from UnityNancyBootstrapper you will gain access to the IUnityContainer of the application and request containers and can perform what ever registrations that your application requires.

public class Bootstrapper : UnityNancyBootstrapper
    protected override void ApplicationStartup(IUnityContainer 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(IUnityContainer existingContainer)
        // Perform registation that should have an application lifetime

    protected override void ConfigureRequestContainer(IUnityContainer container, NancyContext context)
        // Perform registrations that should have a request lifetime

    protected override void RequestStartup(IUnityContainer 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.

protected override IUnityContainer GetApplicationContainer()
    // Return application container instance

If you end up overriding GetApplicationContainer(), you will have to manually add the EnumerableExtension to your container so that it is able to resolve IEnumerable<T> types properly (something that Unity has poor support for).


Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information see the .NET Foundation Code of Conduct.

Contribution License Agreement

Contributing to Nancy requires you to sign a contribution license agreement (CLA) for anything other than a trivial change. By signing the contribution license agreement, the community is free to use your contribution to .NET Foundation projects.

.NET Foundation

This project is supported by the .NET Foundation.


Copyright © 2010 Andreas Håkansson, Steven Robbins and contributors


Nancy.Bootstrappers.Unity is licensed under MIT. Refer to license.txt for more information.