Currently I have a Process that all users of a website undergo. (Process covers multiple controllers and views).
I have a request to use the same process overall (but with variations) for a separate type of Customer. Rather than fill my affected controllers with if thens
I can see I have one of 2 options.
1) Create variations on the controller (backed by a common abstract class for the common features), and figure out how to call a specific controller based on customer type, or keep the controller structure simple, and pass in a dependency that contains the functionality that will vary.
I am leaning towards the second option, but this means I will need to be able to tell simple injector to register different classes with the same interface, and then, depending on a parameter which won't be known until a customer logs in, instantiate the correct class.
ie (I know this code won't work as is)
//in Simple Injector Initialize
container.Register<ICustomerProcess, RetailCustomer>(Lifestyle.Scoped);
container.Register<ICustomerProcess, CommercialCustomer>(Lifestyle.Scoped);
And then, when a Customer is Loaded and Authenticated, then directed to a controller that needs ICustomerProcess, Simple Injector will pass in the appropriate class, RetailCustomer or CommercialCustomer
What I can't see from the Simple Injector documentation is how this achieved. So is it even possible (and if so, can someone explain how as my knowledge of Simple Injector is limited and right now I keep going round in circles!