I implemented dependency injection in MVC 3 framework and following the instructions.
This worked, but I have a few questions regarding this:
Here is my implementation:
public interface ID { string MReturn(); }
And the classes implementing this interface:
public class D:ID { public string MReturn() { return "Hi"; } } public class E : ID { public string MReturn() { return "HiE"; } } public class F : ID { public string MReturn() { return "Hif"; } }
In bootstrapper class
private static IUnityContainer BuildUnityContainer() { var container = new UnityContainer(); container.RegisterType<ID, D>(); container.RegisterType<IController, HomeController>("feedbackRepo"); container.RegisterType<ID, E>(); container.RegisterType<ID, F>();
Now my question
"I want to set the class of service D in the constructor of the Homecontroller, but according to the code above, it sets" class F "in the constructor.
Is there any way to do this? Any modification of the above code?
source share