Home > Essentials > DXCore extensible plug-ins mechanism

DXCore extensible plug-ins mechanism

July 2nd, 2010

The DXCore has a mechanism for creating extensible plug-ins. Using the existing architecture gives some benefits:

  1. Child plug-ins that extend your plug-in are managed by our demand-loading architecture.
  2. Creating a child plug-in can be done in a component-based manner. That is, the user can drop your “extension” component on their plug-in designer surface to extend your plug-in. Using this architecture is not hard:

1. Install the parent plug-in as a system plug-in. This is pretty easy — just copy the plug-in to the DXCore bin\System subdirectory instead of bin\Plugins. Also, in the AssemblyInfo file of your plug-in, change the first parameter of the DXCoreAssemblyAttribute to DXCoreAssemblyType.SystemPlugIn. Making the parent plug-in a system plug-in will ensure that it is loaded before any child plug-ins.

2. Create a new class library to hold your plug-in extension component. This assembly must be signed and installed to the GAC so that the parent and child plug-ins can use it at runtime. In addition, it should be copied somewhere in the Visual Studio build path so that plug-ins can compile against it. An easy place is be to simply copy it to the DXCore bin directory.

3. Derive a new plug-in extension (e.g. “PasteAsExtension”) from DevExpress.CodeRush.Core.ExtensionBase. This will be the component that child plug-ins can use to extend the parent plug-in. Add public properties and events to the new plug-in extension that child plug-ins can set and handle. Most importantly, you should override the DevExpress.CodeRush.Core.ExtensionBase property and return a (reasonably) unique string name to identify your plug-in extension (e.g. “Brinkman.PasteAs”). The plug-in extension goes into your class library.

4. In your parent plug-in, use code like this to access the plug-in extensions:

Dim extensions() As PlugInExtension = CodeRush.PlugInExtensions.Item(“Brinkman.PasteAs”);

Use the same string name that you return in the ExtensionCategory property of your plug-in extension. This will cause the demand-loader to load any child-plug-ins using your plug-in extension if they aren’t loaded already. The PlugInExtention array can be type-cast to your plug-in extension type in order to access properties and trigger events to get data from the child plug-ins.

Products: DXCore
Versions: all
VS IDEs: 2005 and up
Updated: Oct/18/2011
ID: D006

Similar Posts: