问题
Can someone please help me understand several things?
- Do I still have to register PerRequestModule to use LifeStylePerWebRequest? I use Castle.Windsor 3.2.0.0 and it seems everything works without this module. I definetly remember that there was an exception before that tells me "You forget to register this module".
- What "objects tracked by release policy" really means? I use several Components with LifeStyleTransient but when I Resolve one I get it in "objects tracked by release policy" property, when I Resolve others I don't get them there.
- How can I check the actual objects stored inside the container (and their number)?
回答1:
1) I guess since version 3.x PerRequestModule will be automatically registered by windsor.
2) An object will be tracked by windsor only if needed(for ex if its lifestyle is Transient and it implements IDisposable interface).
3) You can run unit tests checking for handlers or manually set a debug point once you registered all components and navigate with VS viewer container object: it has a property that lists all registered components.
来源:https://stackoverflow.com/questions/18576350/perwebrequest-and-transient-lifestyles