What is preferred option of component resolution with castle windsor Io开发者_StackOverflow中文版C container: Resolve by type or resolve by key or by type and key?
What is differences?
In which situatuation should I use one approach and in which others?
You should not resolve at all. Well, actually let me rephrase - you should only resolve once.
When you resolve, 99% of the time you will just specify the type - "I want an IFoo
". That makes things simpler and more flexible.
Cases where you do want to resolve by name are usually when you have multiple components for a given service and you want an instance of a single, non-default component. One particular scenario is in multi-tenant applications where you have component per tenant.
精彩评论