开发者

Resolve by key or by type

开发者 https://www.devze.com 2023-03-31 18:09 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号