Skip to content

lucascebertin/Nancy.Bootstrappers.DryIoc

Repository files navigation

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

Usage

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

Customizing

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

using Nancy;
using Nancy.Bootstrapper;
using Nancy.Bootstrappers.DryIoc;
using DryIoc;
 
public class Bootstrapper : DryIocNancyBootstrapper
{
    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 Maksim Volkau and contributors

License

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

About

Nancy bootstrapper for the DryIoc container

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published