Plug-Ins and Dynamic ControllersPosted in BlogSvc, MVC by JarrettV on 2/11/2009 11:57:48 PM - CST
Update: The content of this post is out of date. The concept of plug-ins has since been expanded to support more scenarios, including widgets, plug-ins, and controllers.
The following types are pluggable:
|Service Level Plug-ins||Default Type||Collection Plug-ins||Default Type|
The Service Level plug-ins can all be controlled using the <StructureMap> configuration section in the web.config file.
The following example shows how to set properties on the blog collection to use the Blog Plug-in:
The RouteService registers routes on the collections first. Then it registers the default routes. Special care must be taken when registering routes so they occur in the correct order. Also, plug-in routes should take care to use the collection constraint so that routes are properly overridden only on collections using the RouteService plug-in.
Controllers are dynamically instantiated using the StructureMap ObjectFactory. Therefore, plug-ins can provide new routes and handle them with new controllers. Currently, new routes are limited to collection plugins that fire the RegisterRoutes event. This will be extended in the future to support routes outside of collections for things such as widgets.
I am currently flushing out the Widget story and I'm leaning towards a combination of techniques using PartialRequests and Modularity. If you have any suggestions for widget support, please leave a comment below.