Object Lifetime
One of the responsibilities of a DI container is to manage the lifetime of objects that it creates. It should decide when to create a new instance of the given type and when to use an existing instance. It should also take care of disposing of objects when they are not used anymore. Ninject has a strong support for managing Object Lifetime in different situations. Whenever we define a binding, we can declare the scope of the object instance being created. Within that scope, the object instance will be reused and exist exactly once for each binding. Note that an object is not allowed to have a dependency on an object with shorter lifetime.
Transient scope
In Transient scope, the object lifetime is not managed by Ninject. Whenever ...
Get Mastering Ninject for Dependency Injection now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.