Skip to content
This repository

This Ninject extension allows that child kernels can be defined.

Octocat-spinner-32 lib Changed build configuration for the Buildserver September 17, 2010
Octocat-spinner-32 nuget Updated description for nuget package December 27, 2011
Octocat-spinner-32 src The default constructor scorer only looks at bindings in the child ke… February 06, 2013
Octocat-spinner-32 tools Update NAnt config for Windows 8 March 20, 2014
Octocat-spinner-32 .gitignore Updated description for nuget package December 27, 2011
Octocat-spinner-32 HowToBuild.txt Updated How to Build - Reference teamcity.bbv.ch instead of codebetter January 10, 2014
Octocat-spinner-32 LICENSE.txt Added License August 16, 2010
Octocat-spinner-32 Ninject.Extensions.ChildKernel.build Changed build scripts to support pull request builds on teamcity March 19, 2014
Octocat-spinner-32 Ninject.build Revert "Changed the build scripts that WP7 Uni Tests are not executed… March 20, 2014
Octocat-spinner-32 Ninject.include Fixed build script that version is not changed during dependency vers… March 20, 2014
Octocat-spinner-32 ReleaseNotes.txt Updated version to 3.2.0 March 21, 2014
Octocat-spinner-32 UnzipDependencies.cmd Improved Build scripts to allow the creation of zip files with a spec… December 06, 2010
Octocat-spinner-32 build-alpha.cmd Updated to NuGet 1.6 and added support for prerelease packages December 22, 2011
Octocat-spinner-32 build-beta.cmd Updated to NuGet 1.6 and added support for prerelease packages December 22, 2011
Octocat-spinner-32 build-rc1.cmd Updated to NuGet 1.6 and added support for prerelease packages December 22, 2011
Octocat-spinner-32 build-release.cmd Updated to NuGet 1.3 May 03, 2011
Octocat-spinner-32 build.cmd Changed to use the common build files October 17, 2010
Octocat-spinner-32 readme.txt Updated readme: November 29, 2011
readme.txt
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 cant resolve are passed
to the parent kernel.

Restrictions:
- 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.
- The default behavior of Ninject that classes are bound to themself if not explicit still
  exists. But in this case this will be done by the top most parent. This means that
  this class can not have any dependency defined on a child kernel. I strongly suggest to
  have a binding for all objects that are resolved by ninject and not to use this default behavior.

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 is the same instance. And all share the same bar.
Something went wrong with that request. Please try again.