How to determine if a component is resolvable from an IHandlersFilter implementation

匆匆过客 提交于 2019-12-12 00:53:21

问题


I am trying to write a Castle Windsor v3 IHandlersFilter implementation that will filter out handlers that cannot be resolved. This is in an effort to optionally restore the old (pre-castle 3) behavior of ResolveAll (How to revert to old CollectionResolver behavior in Castle 3?)

My question is, from the SelectHandlers method, what is the best way (if any) to determine which of the input IHandlers are resolvable? I have experimented with the IHandler.CanResolve method, but it takes parameters that are a bit more advanced than I typically deal with, so I'm not sure how to use the method properly.


回答1:


You can check handler.CurrentState == HandlerState.Valid

However be aware this is based on what Windsor can determine statically, therefore the answer may not always be 100% accurate (for example some components may have dynamic dependencies, so they will appear as unresolvable here, yet you'll be able to successfully resolve them when you try).



来源:https://stackoverflow.com/questions/8567780/how-to-determine-if-a-component-is-resolvable-from-an-ihandlersfilter-implementa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!