问题
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