Skip to content
This repository

Nancy bootstrapper for the StructureMap container

Removed explicit lifetime from request scoped registrations.

SM3 won't resolve a type if it's registered in the nested
container as a singleton and something takes a dependency on it.
Worked around it by detecting if the container is a nested container
and removing the explicit lifetime call.
latest commit ecbddbf862
Steven Robbins grumpydev authored
Octocat-spinner-32 dependencies Fixed and updated to honour lifetimes April 12, 2014
Octocat-spinner-32 src Removed explicit lifetime from request scoped registrations. April 12, 2014
Octocat-spinner-32 .gitignore Update to use shared assembly info November 02, 2011
Octocat-spinner-32 .gitmodules Update .gitmodules March 08, 2014
Octocat-spinner-32 how_to_build.txt Updated Rake, nuspec and dependencies July 24, 2011
Octocat-spinner-32 license.txt Added MIT license file July 09, 2011
Octocat-spinner-32 rakefile.rb Update rakefile.rb February 15, 2013
Octocat-spinner-32 readme.md Update readme.md April 01, 2013
readme.md

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

Usage

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

Customizing

By inheriting from StructureMapNancyBootstrapper you will gain access to the IContainer of the application and request containers and can perform what ever reqistations that your application requires.

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

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

    protected override void RequestStartup(IContainer 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 IContainer GetApplicationContainer()
{
    // Return application container instance
}

Contributors

Copyright

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

License

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

Something went wrong with that request. Please try again.