You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bartelink edited this page Sep 17, 2012
·
9 revisions
This is basically the same as InTransientScope() at least when it comes to the lifecycle and the decision which object is injected. As with InTransientScope a new instance is injected for each dependency. The difference to InTransientScope is that bindings with this scope will be deactivated after the object that gets the instance injected is collected by the garbage collector. E.g. the container disposes the object when it is not used anymore.
public class Foo
{
public Foo(Bar bar) { ... }
}
public class Bar : IDisposable { ... }
Bind().ToSelf().InParentScope();
In this example Bar gets disposed by Ninject as soon as Foo gets collected by the garbage collector [or actively released e.g. by per-call Releasing of a scoping object].