Let’s say I have a (crappy pseudo code):
interface IUserService
{
....
User CreateUser(bunch of parameters)
....
}
With one implementation that get’s injected into a bunch of different controllers.
The concrete UserService is injected with a
interface IHRService
{
bool ValidateInfo(user _user)
}
This is for additional/optional validation and has at least 2 implementations. ValidateInfo is called from UserService’s CreateUser function. I want to inject different IHRService into UserService based on what controller is calling the UserService – this is so I can call the same CreateUser function from multiple different screens and be able to skip the additional validation in one but not the other.
Is something like this possible with windsor or am I going about this the wrong way? Should I get the correct IHRService inside of the particular controller then pass that into the CreateUser function?
I don’t know if I understood you well but it seems that you could inject into UserService and abstract factory that creates a concret implementation of IHRService depending on some options at runtime. Windsor deals with abstract factories very well for that scenarions. Does it make sense ?