I have got a method in my MVC 3 controller class, that accepts two parameters:
public ActionResult MyMethod(string providerName, IAuthProvider providerImpl)
I have got multiple implementations of IAuthProvider registered by its names in the Unity container as follows:
container.RegisterType<IAuthProvider, FacebookAuthProvider>("facebook");
container.RegisterType<IAuthProvider, GoogleAuthProvider>("google");
So, when the method is called I’d like the second argument to be resolved based on the first argument. For example, if the first argument was ‘facebook’ the second one must be resolved from the container to an IAuthProvider implementation registered by the name ‘facebook’.
I look forward to any ideas!
Remark: I use Unity.2.1.505.0
There’s so many things wrong with your example.
MyMethodthen look into the request values and self create the AuthProvider object and return the object.