Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
This Ninject extension allows that child kernels can be defined.
C# Shell

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/Ninject Changed build configuration for the Buildserver
nuget Update sln csproj and nuspec
src
tools Updated build script to mono 3.4
.gitignore Updated description for nuget package
HowToBuild.txt Updated How to Build - Reference teamcity.bbv.ch instead of codebetter
LICENSE.txt Added License
Ninject.Extensions.ChildKernel.build Added mono settings to test compilation.
Ninject.build Revert "Changed the build scripts that WP7 Uni Tests are not executed…
Ninject.include Updated build script to mono 3.4
README.md Update README.md
ReleaseNotes.md Update and rename ReleaseNotes.txt to ReleaseNotes.md
UnzipDependencies.cmd Improved Build scripts to allow the creation of zip files with a spec…
build-alpha.cmd Updated to NuGet 1.6 and added support for prerelease packages
build-beta.cmd Updated to NuGet 1.6 and added support for prerelease packages
build-rc1.cmd Updated to NuGet 1.6 and added support for prerelease packages
build-release.cmd Updated to NuGet 1.3
build.cmd Changed to use the common build files

README.md

Ninject.Extensions.ChildKernel NuGet Version NuGet Downloads

This Ninject extension allows that child kernels can be defined. A child kernel is a Ninject kernel that has a parent kernel. All requests that it can't resolve are passed to the parent kernel.

Getting Started

Example:

public class Foo
{
  public Foo(IBar bar)
  {
    this.Bar = bar;
  }

  public IBar Bar { get; private set; }
}

public class Bar
{
}

var parentKernel = new StandardKernel();
parentKernel.Bind<Bar>().ToSelf().InSingletonScope();

var childKernel1 = new ChildKernel(this.parentKernel);
childKernel1.Bind<Foo>().ToSelf().InSingletonScope();

var childKernel2 = new ChildKernel(this.parentKernel);
childKernel2.Bind<Foo>().ToSelf().InSingletonScope();

var foo1 = childKernel1.Get<Foo>();
var foo2 = childKernel2.Get<Foo>();
var foo3 = childKernel1.Get<Foo>();

In this example foo1 and foo2 will be different instances. foo1 and foo3 are the same instance. And all share the same bar.

Note

  • Objects that are resolved by the parent kernel can not have any dependency to an object defined on a child kernel. This is by design. Otherwise it would be possible to access objects on another child kernel if the object is defined as singleton.
  • Since version 3.0, implicit bindngs are resolved on the child kernel and not the parent kernel anymore.

Documentation

https://github.com/ninject/Ninject.Extensions.ChildKernel/wiki

CI build status

Build Status

Something went wrong with that request. Please try again.