Export (0) Print
Expand All

Solution Extender Sample

Visual Studio 2005
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

The Solution Extender sample creates an alternate view of the Visual Studio solution. The purpose of this sample is to demonstrate the use of a document window to create and persist additional information pertaining to the solution.

Security noteSecurity Note

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.  Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

The sample demonstrates how to autoload a package based on CMDUICONTEXT GUID using UICONTEXT_SolutionExists in particular. For more information relating to VSPackage loading and autoloading, see Loading VSPackages.

The Solution Extender sample also demonstrates implementation of Automation Extenders. The Solution Extender sample demonstrates two extensions:

  • SlnStaticExtender — This is a simple Extender, named "MyExtension", that extends the Solution Browse object as well as the Visual C++, Visual C#, and Visual Basic project browse objects by adding a string valued "MyProperty" using browse objects' intrinsic CATIDs. The Extender is statically registered. See the Automation.rgs script for the registration code. Class CSlnStaticExtenderProvider represents the extender provider and class CSlnStaticExtender represents the extender. In addition, the extender tracks solution open and close events to update extender data because the environment creates and reuses the same Solution Browse Object instance across solution opens/closes for the same Visual Studio session. Also, the extender persists the property value in Solution's Globals or Project's Globals section.

  • SlnDynamicExtender — This is a simple Extender, named SolutionNotes, that extends the Solution and Solution Browse Objects by adding the NoteCount property. The property returns the number of notes in the Solution Notes window. The Extender is dynamically registered during the package SetSite call and unregistered during the package Close call.

    Class CSlnDynamicExtenderProvider represents the extender provider and class CSlnDynamicExtender represents the extender. Files related to the implementation of these extenders are:

    • Automation.idl — contains automation-related interfaces

    • AutomationExtenders.h, .cpp — contain declaration/implementation of classes:

      CSlnStaticExtender

      CSlnStaticExtenderProvider

      CSlnDynamicExtender

      CSlnDynamicExtenderProvider

      Automation.rgs—RGS script for registering the static extender

The default location for the Solution Extender sample is <drive>:\Program Files\Visual Studio 2005 SDK\<build number>\VisualStudioIntegration\Unsupported\SlnExt\SlnExt.

Security noteSecurity Note

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.  Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

To build this sample

  1. Start Visual Studio. Type devenv.exe at the command line.

  2. Open the SlnExt.sln file within Visual Studio.

  3. On the Build menu, choose Rebuild Solution.

  4. Run devenv.exe /setup /rootsuffix exp to merge command bars and other UI items.

To run this sample

  1. Start Visual Studio using the experimental build by typing devenv.exe /rootsuffix exp at the command line.

  2. Open a new project of any type.

  3. In the Solution Explorer, choose the Solution node.

  4. Right-click, choose Solution Notes, and Add New Solution Note or View Solution Notes. You can also display the Solution Notes toolbar icon.

To run the SlnStaticExtender after building the sample

  1. Start Visual Studio using the experimental build by typing devenv.exe /rootsuffix exp at the command line.

  2. Create or open a solution.

  3. With the Properties window visible, select the Solution node in Solution Explorer.

    NoteNote

    Notice the new property MyProperty in the Properties window. The MyProperty property will be displayed in the Properties window when a Visual Basic, C#, or Visual C++ project is selected in Solution Explorer.

To run the SlnDynamicExtender after building the sample

  1. Start Visual Studio using the experimental build by typing devenv.exe /rootsuffix exp at the command line.

  2. Create or open a solution.

  3. With the properties grid visible, select the Solution node in the Solution explorer.

    NoteNote

    Notice the new property NoteCount in the Properties window. You can also access the NoteCount property by using the Solution object DTE.Solution.Extender("SolutionNotes").NoteCount.

Once you have built the sample, you can:

  • Add to the Solution commands that are available through the Context menu on the Solution Node; the commands are only visible when a solution is open

  • Provide an alternate view of solution.

  • Persist information into .sln and .suo files.

  • Create a Document window to edit a piece of Solution State.

  • Extend DTE automation model: DTE.SolutionNotes, DTE.Events.SolutionNotesEvents

The following table lists the interfaces that are implemented by the Solution Extender sample.

Implemented Interfaces

IDispatch

IExtenderProvider

IOleCommandTarget

ISelectionContainer

IServiceProvider

IVsBroadcastMessageEvents

IVsCodeWindow

IVsHierachy

IVsHierarchy

IVsOutputWindowPane

IVsPackage

IVsPersistSolutionOpts

IVsPersistSolutionProps

IVsSolutionEvents

IVsSolutionPersistence

IVsTextLines

IVsUIHierachy

IVsWindowFrame

IVsWindowFrameNotify

IVsWindowPane

The following table lists the interfaces that are called by the Solution Extender sample and their associated services.

Called Interfaces Associated Services

ILocalRegistry

SLocalRegistry

IOleComponentUIManager

SOleComponentUIManager

ITrackSelection

STrackSelection

IVsRunningDocumentTable

SVsRunningDocumentTable

IVsShell

SVsShell

IVsSolution

SVsSolution

IVsUIShell

SVsUIShell

See Also

Community Additions

ADD
Show:
© 2014 Microsoft