Nov 10, 2009 at 2:46 AM
Edited Nov 10, 2009 at 3:17 AM
NachaPaymentProcessor(ITaxStrategy taxcalculation) : IPaymentProcessor
ITaxStrategy - the concrete type to return is based on some context type say "State".
IPaymentProcessor - the concrete type to return is based on PaymentType enumeration.
lets assume we had a "Payment" available with properties: State, PaymentType.
here is how some PSEUDO code on how i would implement something like that:
var taxstrategylocator = CommonServiceLocator.Resolve<ITaxStrategyLocator>();
var processorstrategylocator = CommonServiceLocator.Resolve<IPaymentProcessorLocator>();
var processor = processorstrategylocator.GetBy(paymenttypecontext, strategylocator.GetBy(statecontext));
inside service locator for both of these we would have to "new" the concrete type. that is one approach.
does unity have a policy system to enable strategy resolving?