Use Case
| • | You've written your own extension that extends a certain extension point for which there is already another competing extension. |
| • | You want to enable an extension that is disabled by default. |
| • | Relevant Architecture |
Relevant Files
| • | ClearCanvas.Desktop.Executable.exe.config |
Sample Code
[ExtensionOf(typeof(LayoutManagerExtensionPoint), Enabled = false)]
public class MyLayoutManager : LayoutManager
{
/// ...
}
<ClearCanvas.Common.ExtensionSettings>
<setting name="ExtensionConfigurationXml" serializeAs="Xml">
<value>
<extensions>
<extension class="MyLayoutManagerAssembly.MyLayoutManager, MyLayoutManagerAssembly" enabled="true" />
<extension class="ClearCanvas.ImageViewer.Layout.Basic.LayoutManager, ClearCanvas.ImageViewer.Layout.Basic" enabled="false" />
</extensions>
</value>
</setting>
</ClearCanvas.Common.ExtensionSettings>
Remarks
Sometimes, you might find that you need to replace an existing extension so that you can change how a particular piece of functionality works. Because all the plugins and extensions in an application are an unordered set, there needs to be some way to configure the application in order to ensure that your extensions are the ones that get used. The example above shows how you might replace the existing LayoutManager in the viewer.
In many cases, a given extension point is used to discover a single extension, which in turn is then used to perform some operation, like the LayoutManagerExtensionPoint in the viewer. Other times, all extensions are discovered and used in some way, for example as options in a list presented to the user. In such cases, it is useful to be able to order the extensions so that the application's behaviour is predictable. In addition to configuring which extensions are enabled/disabled, the ExtensionSettings also determine the order in which extensions are processed when discovered via the corresponding extension point.
One other noteworthy thing in the example is that MyLayoutManager is disabled by default (look at the ExtensionOf attribute). This is quite handy when you have some specialized piece of functionality that isn't used in a typical distribution of the software, but you want to install the plugin your extension resides in, for example because it has some other functionality in it that is needed.
Examples in Code Base
| • | None currently |