Defining and Reacting to Commands
One of the primary ways you interact with a package-based extension is by issuing it a command (perhaps via a Visual Studio menu, or a toolbar button press event). A command, in the VSPackage environment, is nothing more than a message to the extension that triggers an action. For example, if we have an extension that computed the total lines of executable code within a code editor window, we would probably trigger that computation via a command. Or, if our extension was capable of printing out a file loaded into Visual Studio, we would initiate the printing via a print
command.
Listing 15.2 shows the command file code that was generated with our "Hello, World"
custom command project.
Get Microsoft Visual Studio 2015 Unleashed, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.