Skip to content

SkyKick/Ninject.Extensions.ChildKernel

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

This Ninject extension allows that child kernels can be defined.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 88.8%
  • PowerShell 11.2%