Mugen Injection [Child container]
Sometimes it is necessary to separate parts of the application to avoid duplicated bindings (e.g. Plugins that share interfaces from the main application) or to ensure that some part can not have a side affect to other parts (e.g. to ensure that wrong scoping has no influence). In these cases you can use the child container, which forwards any unknown request to the parent container.
This code shows how it works:
// Create your MugenInjector. _injector = new MugenInjector(); _injector.Bind<string>().ToConstant("parent"); _injector.Bind<string>().ToConstant("parentNamed").NamedBinding("parent"); using (var child = _injector.CreateChild()) { //_injector contains child _injector.ChildInjectors.Contains(child); //injector equals to _injector var injector = child.GetParent(); child.Bind<string>().ToConstant("child"); //s equals to "child" var s = child.Get<string>(); //parent equals to "parentNamed" because child doesn't has a named binding with name = "parent" var parent = child.Get<string>("parent"); }