ploeh/ploeh.github.com — pull request #31 by Lumirris (2013-08-14 15:40:43+00:00)
Title: Comment on 2013-01-10-RoleInterfaceRoleHint.html

Asked question about how to implement a fall-through mechanism in the GetCalculator method shown in the post. If the formatting is not what you want, here's the gist of what I was asking:

Could you expand upon how you might implement the fall-through mechanism you mentioned in your IShippingCostCalculatorFactory implementation, where more than one candidate can handle the shippingMethod?

How would you sort your IEnumerable candidates in GetCalculator() so that the candidate returned by First() is the one specifically meant to handle the ShippingMethod when one exists, and the default implementation when a specific one doesn't exist?

I considered using FirstOrDefault(), then returning the default implementation if the result of the query was nothing, but my default IHandleShippingMethod implementation always returns True from CanHandle() - I don't know what other value it could return.