Partager via


Extend the SharePoint connections node in Server Explorer

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

In Visual Studio, you can connect to local SharePoint sites on the development computer by using the SharePoint Connections node in the Server Explorer window. This node displays many of the components of local SharePoint sites in a hierarchical tree view. For example, you can view the lists, document libraries, and content types on local sites. For more information about using Server Explorer to connect to local SharePoint sites, see Browse SharePoint connections using Server Explorer.

You can extend the SharePoint Connections node by creating extensions for existing nodes, or by creating a custom node type and adding it to the hierarchy of nodes.

Tasks for extending the SharePoint connections node

To extend an existing node, create a Visual Studio extension that implements the IExplorerNodeTypeExtension interface. When you extend a node, you can add functionality to the node such as your own shortcut menu items or custom properties. For more information, see How to: Extend a SharePoint node in Server Explorer.

To create a custom node type, create a Visual Studio extension that implements the IExplorerNodeTypeProvider interface. Create a custom node if you want to display components of SharePoint sites that are not displayed in Server Explorer by default. For example, Server Explorer does not display the Web Part gallery of a SharePoint site by default, but you can add a custom node that does this. For more information, see How to: Add a custom SharePoint node to Server Explorer and Walkthrough: Extend Server Explorer to Display Web Parts.

Add custom properties to nodes

When you extend a node or create a custom node type, you can add custom properties to the node. The properties appear in the Properties window when the node is selected.

There are two types of custom properties you can add to a node:

Get data for built-in nodes

All of the built-in nodes provided by Visual Studio include some data about the SharePoint component that they represent. For example, a node that represents a list on the SharePoint site provides some data about the list, such as the title and the URL of the default view for the list.

To access this data, retrieve a data object from the Annotations property of the IExplorerNode object that represents the node you are interested in. The type of the data object depends on the type of the node.

The following code example demonstrates how to get the data object for a list node. To see this example in the context of a larger example, see How to: Get data for a built-in SharePoint node in Server Explorer.

Dim nodeInfo As IListNodeInfo = node.Annotations.GetValue(Of IListNodeInfo)()
IListNodeInfo nodeInfo = node.Annotations.GetValue<IListNodeInfo>();

The following table lists the data object types for each built-in node type.

Node type Data object type
SharePoint site node IExplorerSiteNodeInfo
Content type IContentTypeNodeInfo
Feature IFeatureNodeInfo
Field IFieldNodeInfo
List IListNodeInfo
List template IListTemplateNodeInfo
List view (Microsoft.SharePoint.SPView) IListViewNodeInfo
Workflow association IWorkflowAssociationNodeInfo
Workflow template IWorkflowTemplateNodeInfo

For more information about using the Annotations property, see Associate custom data with SharePoint tools extensions.

See also