GithubHelp home page GithubHelp logo

512948935 / nancy.bootstrappers.ninject Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nancyfx/nancy.bootstrappers.ninject

0.0 1.0 0.0 4.07 MB

Nancy boostrapper for the Ninject container

License: MIT License

Ruby 22.89% C# 77.11%

nancy.bootstrappers.ninject's Introduction

A bootstrapper implementation, for the Nancy framework, based on the Ninject 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 in your application is to install the Nancy.Bootstrappers.Ninject nuget package.

Customizing

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

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.

protected override IKernel GetApplicationContainer()
{
    // Return application container instance
}

You can also override the CreateRequestContainer method so that you could customize your child container. By default, the request container's binding scope is singleton as this would be the most common case.

protected override IKernel CreateRequestContainer()
{
    // Return request contaner instance
}

Contributors

Copyright

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

License

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

nancy.bootstrappers.ninject's People

Contributors

gatapia avatar grumpydev avatar horsdal avatar khellang avatar scott-xu avatar stabbylambda avatar thecodejunkie avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.