Let’s try this out. We’ll define the following extension point:
[ExtensionPoint()]
public class TextEditorToolExtensionPoint : ExtensionPoint<ITool>
{
}
Now assuming someone out there has created some tools that extend TextEditorToolExtensionPoint, our component needs to fulfill its end of the bargain by instantiating those tools and providing their actions to be integrated into the desktop.
To instantiate tool extensions, we’ll use a ToolSet. Let’s add a field to our component of type ToolSet, and initialize the field in our constructor:
private ToolSet _toolSet;
public TextEditorComponent()
{
_toolSet = new ToolSet(new TextEditorToolExtensionPoint(), ...);
}
The first parameter to the ToolSet constructor is an instance of the extension point we defined: this tells the ToolSet to create one instance of each tool class that extends this point. The second argument, according to the ToolSet constructor signature, should be of type IToolContext. However, IToolContext itself is not sufficient. We actually need to extend IToolContext with an interface of our own that will provide new tools with access to objects or values that it may need to operate on.