views:

138

answers:

1

Let say we defined an interface for tax service as ITaxService, and we got more than one implementation of TaxService (by region) however I wanted to attach a specific tax implementation to a specific customer from the spcific region.

Will DI help in this scenario? How? "code snippet would be much appreciate"

+1  A: 

Without knowing more, this seems like something suited to an implementation of a strategy pattern (http://en.wikipedia.org/wiki/Strategy_pattern).

A Dependency Injection tool like Windsor could be used as a form of factory to determine the correct strategy (tax service) to use in a given situation (say, for example, keyed on the region identifier), but it strikes me more as a use of the tool as an object repository rather than specifically for the purpose of dependency injection.

jasondoucette