Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 31, 2007 03:59 AM by tgmdbm
Dec 30, 2007 11:51 PM|LINK
ControllerBuilder.Current.SetControllerFactory( typeof( MyControllerBase ), typeof( MyControllerFactory ) );
MyControllerBase contains a reference to the data store and MyControllerFactory attaches the controller to the instance of the data store. This makes the controllers more testable because i can mock the data store.
However, the above code means "use MyControllerFactory when creating a controller of type MyControllerBase",
NOT when creating a controller which derives from MyControllerBase. So i would have to repeat this line for each controller.
Changing the behaviour of this will make it much easier to provide a ControllerFactory for a set of related Controllers
Dec 31, 2007 12:09 AM|LINK
Got my vote.
Dec 31, 2007 01:09 AM|LINK
Oh, and also, instead of supplying a Type, it would make much more sense if I could supply an instance of my ControllerFactory.
(i knew there was something i'd forgotten)
Dec 31, 2007 03:45 AM|LINK
Use ControllerBuilder.SetDefaultControllerFactory(typeof(MyControllerFactory)). Then you can implement the base class resolution logic in your own factory and you do not need to call SetControllerFactory for all of your controllers.
Dec 31, 2007 03:59 AM|LINK
That's what i've had to do. But if i have 2 or more "families" of controllers, each with their own base class, this gets a bit ugly.
My point is that the idea of SetControllerFactory is useful for when you don't want to override the behaviour for every controller. But it could be even more useful if it did a bit more work for me.