Thursday, January 20, 2011

aspnet: Add Plug-in Capability to a web application

Adding plug-in capability to a web application is not something you will need for every applications. If you want to hook up to a web application for specific events (eg a defect is created in the defect tracking system) and you don't have or want to mess with the original application, plug-ins are a great way to handle these situations. In order to support plug-in, you need to define your plug-in interfaces, base classes, abstract classes and event model.

Once you have these setup in your main application, you can write the plug-ins based on the interfaces and base classes. Your main application will invoke events and based on what events you are subscribed to, your plug-in class will be called. An object with current state will be passed to your class as the event args.


During the application start-up, check for any plug-in files in the configuration file and cache an instance of all plug-ins in an application variable. On all defined events, loop through this array and call the appropriate method to invoke the plug-in method.


download code

-paul