Export (0) Print
Expand All

Implementing and Using Automation Extenders 

The Automation Extenders portion of the Visual Studio automation model provides the ability to add or filter properties that are displayed in a specified project type. For example, Visual Studio includes a Visual Basic code model with an object that represents a Visual Basic class. You can use Automation Extenders, for example, to add new properties to the existing properties in a middle-tier business object. You can also use this model to filter the properties that display in the project's property page.

Here is one possible scenario. A user selects a class item in Solution Explorer and modifies the code that the wizard creates. Alternatively, a user places the editor's insertion point inside the class definition. Consequently, the Properties window could display additional properties of the class. The properties are pertinent because it is a middle-tier business object definition. Automation Extenders allow you to do this, and more.

Following are the objects in the Automation Extenders object model.

Object Name Description

IExtenderProvider interface

Represents a known Extender Provider.

IExtenderProviderUnk interface

Represents an unknown Extender Provider.

IExtenderSite interface

Site object that hosts the Automation Extender.

IFilterProperties interface

When implemented, allows an Extender to prevent specified properties from displaying in the Properties window.

ObjectExtenders object

Provides access to Automation Extenders.

By using these objects, you can:

  • Add properties to objects in Visual Studio, accessible either through the Properties window or through code.

  • Hide properties so that they do not appear in the Properties window.

  • Replace a property with one of the same name, but one that accepts only a specific set of values.

Automation Extenders Example

For an example of how to use Automation Extenders to add properties and methods to a Visual Studio object, see the sample, Solution Extender Add-in, on the Visual Studio Automation Samples Web page.

The SolutionExtender sample extends both the solution Properties window display object as well as the DTE.Solution automation object. It adds four new properties: Notes, Created, LastAccessed, and LastModified. You can reference the new properties by using DTE.Solution as shown in this macro:

Sub ShowNotes()
    Dim extender As Object
    extender = DTE.Solution.Extender("SolutionMisc")
    MsgBox(extender.Notes)
End Sub

To run the sample

  1. Build and deploy the SolutionExtender solution.

  2. Add the registration entries in the SolutionExtender.reg by using the command line registry file SolutionExtender.reg.

  3. Run devenv.exe and either open or create a new solution.

  4. Select the Solution node in Solution Explorer to view the newly-added properties.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft