Reputation: 514
I am new in MVC. I am following Steve Sanderson's MVC book to create a sample MVC project. In the project, ninject was used to implement a custom ControllerFactory. I am not understanding the part that Controller classes can be resolved in the ControllerFactory without any prior binding statements. How did the kernel object obtain the Controllers information at the first place?
Thanks a lot
Andy
Upvotes: 1
Views: 109
Reputation: 31630
Most likely he creates a child class of DefaultControllerFactory, which represents the controller factory that is registered by default. From MSDN it is noted that: This class provides a convenient base class for developers who want to make only minor changes to controller creation. So one could override the GetControllerInstance method, and use Ninject to create the controller based on the controller type.
However, the current controller factory would have to be registered in the Global.asax file, specifically in Application_Start(), using SetControllerFactory, passing in the child class type into the type constructor. So this would effectively tell MVC that the custom controller class should be used to create controllers instead of the Default MVC controller factory.
Upvotes: 1