I'm trying to make sense of a somewhat complicated scenario. Basically if I have class X
that is registered in Castle as LifestyleTransient()
:
Component.For<IX>()
.ImplementedBy<X>()
.LifestyleTransient()
X
looks something like:
public X : IX
{
private IY _y;
public X(IY y)
{
_y = y;
}
....
}
and Y
is registered thus:
Component.For<IY>()
.ImplementedBy<Y>()
.LifestylePerWebRequest()
and looks like:
public Y : IY, IDisposable
{
private Object obj;
public Y()
{
obj = new Object();
}
public void Dispose()
{
obj.Dispose();
}
}
If I create an instance of X
and Release
it:
WindsorContainer Container;
IX x = Container.Resolve<IX>();
Container.Release(x);
when does Dispose
get called on Y
? Is it at the end of the web request or when the instance of x is released? Does Dispose
get called at all?!
Note: This is a somewhat converluted example, my actual example is much more complicated and invloves an MVC ControllerFactory and various other pieces of technology, but the question pretty boils down to the above in it's simpliest form.