Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ninject parent child container hierarchy (like inheritance)

Does Ninject have anything similar to the Unity concept of parent/child containers to provide a basic inheritance model? I googled but didn't find anything.

like image 366
fearofawhackplanet Avatar asked Feb 25 '23 05:02

fearofawhackplanet


2 Answers

Ninject supports container hierarchies using https://github.com/ninject/ninject.extensions.childkernel. See also my article http://www.planetgeek.ch/2010/12/08/how-to-use-the-additional-ninject-scopes-of-namedscope/ about additional scopes for Ninject. Expecially look at the last part. Sometimes it is better using this concept rather than container heirarchies.

like image 110
Remo Gloor Avatar answered Mar 16 '23 21:03

Remo Gloor


There are Activation Blocks. Not aware of specific documentation, but the Cache and Collect article has an example. I'd look in the tests for more examples.

I'm sure @Remo Gloor will be along but I believe the general attitude of the team (and original author) are that Nested Containers are A Bad Idea and hence are not likely to be supported directly in the core (but it may be via an extension - e.g., like Context Preservation

like image 43
Ruben Bartelink Avatar answered Mar 16 '23 22:03

Ruben Bartelink