Discovering and Consuming Shared Content


We have all been given programming tasks in which we just know someone must have already tackled the problem, and we've all faced tight deadlines. In these cases, it is often wise to hit the Internet to find out whether there is community content you can use to your advantage. At a minimum, you may find a partial solution that can speed your development effort and increase your understanding of how you might solve your particular problem.

Visual Studio 2005 provides a formal mechanism for publishing, finding, and consuming community content. In the following sections, we will look at discovering and leveraging this content. We will then demonstrate how you can be an active participant in this community.

Examining Shared Content Types

Visual Studio provides a number of code-sharing opportunities. For example, you might download a project template that defines an observer or singleton pattern, perhaps you'll find a code snippet that inserts a common method for accessing a database, or maybe you'll write a time-saving add-in or macro to share with the community. Visual Studio allows developers to write these types of extensions and more. Table 12.2 describes the many content types that provide opportunities for community sharing and consumption in Visual Studio 2005.

Table 12.2. Shared Content Types

Content

Description

Project Template

Project templates are the sets of files that define a new project. When you create a new project using Visual Studio, you are asked to select a project template. Visual Studio allows for the creation of your own project templates and the consumption of the same.

Starter Kit

Starter kits are just like project templates but typically include additional documentation and step-by-step instruction.

Item Template

Item templates are files that you want to be able to reuse across projects. When you use Visual Studio to add a new item to your project, you are selecting and adding an item template. Item templates define the contents and structure of new items when added to a project. Visual Studio allows you to create and consume custom item templates.

Code Snippet

Code snippets are bits of code that you can add to the Visual Studio IntelliSense feature. You can create your own code snippets and share them with your community. A number of useful snippets are also available for download. We cover creating a custom code snippet in Chapter 7, "Working with Visual Studio's Productivity Aids."

Sample

A number of MSDN sample applications are available for download and installation. These files are typically .zip files and come in multiple languages (C# and VB being the most common).

Control

Controls can be both user and custom controls written for .NET. They may be free to the community and include source code, or they may be made for commercial purposes. You can write and share your own controls using Visual Studio.

Add-Ins & Macros

Add-ins and macros are typically extensions and enhancements to the development environment. Visual Studio supports the creation and sharing of these items. We cover add-ins and macros in-depth in Chapter 11, "Writing Macros, Add-ins, and Wizards."


Finding the Right Content

The first trick to leveraging the knowledge that exists out there is finding it. You have already seen the search feature that is built into the Visual Studio help system. However, it is worth noting that one of the search options is Content Type. This allows you to filter your search based on what you are looking for. For example, if you are looking only for a control or a code snippet, you can limit the search to content that has been tagged as such. Figure 12.22 shows the Content Type drop-down options.

Figure 12.22. Content Type search.


Installing and Storing Shared Content

Visual Studio 2005 provides a tool called the Visual Studio Content Installer. Its role is to both allow content consumers to easily install content as well as help content creators package their content (more on this later). The Content Installer is invoked when you run a .vsi (Visual Studio Installer) file. The Content Installer is a wizard that walks you through installing shared content. The dialog boxes in the wizard are slightly different depending on what type of content you are installing. For example, Figure 12.23 shows the tool installing a Visual Basic code snippet. Notice that it prompts you as to which branch the snippet should be installed under (and thereby accessed from).

Figure 12.23. The Visual Studio Content Installer.


Content that is not a macro, add-in, or snippet gets installed in one of the appropriate Visual Studio locations. There are paths for projects, project templates, and item templates. Figure 12.24 shows the Options dialog box that can be used to manage these paths. Note that if you have a lot of varied project and item templates, you may choose to set these paths to a network share.

Figure 12.24. Setting project and item template storage locations.


We will examine this tool more closely in the upcoming section where we discuss how you can create and package your own content.




Microsoft Visual Studio 2005 Unleashed
Microsoft Visual Studio 2005 Unleashed
ISBN: 0672328194
EAN: 2147483647
Year: 2006
Pages: 195

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net