연습: 서버 탐색기 확장의 SharePoint 클라이언트 개체 모델 호출

이 연습에서는 서버 탐색기SharePoint 연결 노드용 확장에서 SharePoint 클라이언트 개체 모델을 호출하는 방법을 보여 줍니다. SharePoint 클라이언트 개체 모델을 사용하는 방법에 대한 자세한 내용은 SharePoint 개체 모델 호출을 참조하십시오.

이 연습에서는 다음 작업을 수행합니다.

  • 다음과 같은 방법으로 서버 탐색기SharePoint 연결 노드를 확장하는 Visual Studio 확장 만들기

    • 서버 탐색기의 각 SharePoint 사이트 노드 아래에 새 웹 파트 갤러리 노드를 추가합니다. 새 노드에는 사이트에서 웹 파트 갤러리의 각 웹 파트를 나타내는 자식 노드가 포함됩니다.

    • 웹 파트 인스턴스를 나타내는 새 노드 형식을 정의합니다. 새 노드 형식은 새 웹 파트 갤러리 노드 아래에 있는 자식 노드의 기반이 됩니다. 새 웹 파트 노드 형식이 나타내는 웹 파트에 대한 정보가 속성 창에 표시됩니다.

  • 확장을 배포하기 위한 VSIX(Visual Studio Extension) 패키지 빌드

  • 확장 디버깅 및 테스트

참고

이 연습에서 만드는 확장은 연습: 서버 탐색기를 확장하여 웹 파트 표시에서 만드는 확장과 비슷합니다. 하지만 해당 연습에서는 SharePoint 서버 개체 모델을 사용하지만 이 연습에서는 클라이언트 개체 모델을 사용하여 동일한 작업을 수행합니다.

사전 요구 사항

이 연습을 완료하려면 개발 컴퓨터에 다음 구성 요소가 필요합니다.

다음 개념을 알고 있으면 연습을 완료하는 데 도움이 되지만 반드시 필요하지는 않습니다.

  • SharePoint 클라이언트 개체 모델 사용. 자세한 내용은 Managed Client Object Model을 참조하십시오.

  • Microsoft SharePoint Services의 웹 파트. 자세한 내용은 Web Parts Overview를 참조하십시오.

프로젝트 만들기

이 연습을 완료하려면 두 프로젝트를 만들어야 합니다.

  • VSIX 패키지를 만들어 서버 탐색기 확장을 배포하기 위한 VSIX 프로젝트

  • 서버 탐색기 확장을 구현하는 클래스 라이브러리 프로젝트

먼저 프로젝트를 만들어 연습을 시작합니다.

VSIX 프로젝트를 만들려면

  1. Visual Studio를 시작합니다.

  2. 파일 메뉴에서 새로 만들기를 가리킨 다음 프로젝트를 클릭합니다.

  3. 새 프로젝트 대화 상자에서 Visual C# 또는 Visual Basic 노드를 확장한 다음 확장성을 클릭합니다.

    참고

    확장성 노드는 Visual Studio 2010 SDK를 설치한 경우에만 사용할 수 있습니다. 자세한 내용은 위의 필수 구성 요소 단원을 참조하십시오.

  4. 대화 상자 맨 위의 콤보 상자에서 .NET Framework 4를 선택합니다. SharePoint 도구 확장을 사용하려면 이 .NET Framework 버전의 기능이 필요합니다.

  5. VSIX 프로젝트 템플릿을 클릭합니다.

  6. 이름 상자에 WebPartNode를 입력합니다.

  7. 확인을 클릭합니다.

    Visual Studio에서 솔루션 탐색기WebPartNode 프로젝트를 추가합니다.

확장 프로젝트를 만들려면

  1. 솔루션 탐색기에서 솔루션 노드를 마우스 오른쪽 단추로 클릭한 다음 추가, 새 프로젝트를 차례로 클릭합니다.

    참고

    Visual Basic 프로젝트에서는 옵션 대화 상자, 프로젝트 및 솔루션, 일반에서 솔루션 항상 표시 확인란을 선택한 경우에만 솔루션 탐색기에 솔루션 노드가 표시됩니다.

  2. 새 프로젝트 대화 상자에서 Visual C# 또는 Visual Basic 노드를 확장하고 Windows를 클릭합니다.

  3. 대화 상자 맨 위의 콤보 상자에서 .NET Framework 4를 선택합니다.

  4. 클래스 라이브러리 프로젝트 템플릿을 선택합니다.

  5. 이름 상자에 WebPartNodeExtension을 입력합니다.

  6. 확인을 클릭합니다.

    Visual Studio에서 솔루션에 WebPartNodeExtension 프로젝트를 추가하고 기본 Class1 코드 파일을 엽니다.

  7. 프로젝트에서 Class1 코드 파일을 삭제합니다.

확장 프로젝트 구성

확장을 만드는 코드를 작성하기 전에 코드 파일과 어셈블리 참조를 프로젝트에 추가하고 기본 네임스페이스를 업데이트해야 합니다.

프로젝트를 구성하려면

  1. WebPartNodeExtension 프로젝트에서 다음과 같은 이름의 코드 두 개를 추가합니다.

    • SiteNodeExtension

    • WebPartNodeTypeProvider

  2. 프로젝트 메뉴에서 참조 추가를 클릭합니다.

  3. .NET 탭에서 Ctrl 키를 누르고 다음 어셈블리를 선택한 다음 확인을 클릭합니다.

    • Microsoft.SharePoint.Client

    • Microsoft.SharePoint.Client.Runtime

    • Microsoft.VisualStudio.SharePoint

    • System.ComponentModel.Composition

    • System.Windows.Forms

  4. 프로젝트 메뉴에서 WebPartNodeExtension 속성을 선택합니다.

    프로젝트 디자이너가 열립니다.

  5. 응용 프로그램 탭을 클릭합니다.

  6. 기본 네임스페이스 상자(C#) 또는 루트 네임스페이스 상자(Visual Basic)에 ServerExplorer.SharePointConnections.WebPartNode를 입력합니다.

새 노드의 아이콘 만들기

서버 탐색기 확장에 대한 두 아이콘을 만듭니다. 한 아이콘은 새 웹 파트 갤러리 노드를 나타내고, 다른 아이콘은 웹 파트 갤러리 노드 아래의 각 자식 웹 파트 노드를 나타냅니다. 이 연습의 뒷부분에서는 이러한 아이콘을 노드에 연결하는 코드를 작성합니다.

노드의 아이콘을 만들려면

  1. WebPartNodeExtension 프로젝트의 프로젝트 디자이너에서 리소스 탭을 클릭합니다.

  2. **이 프로젝트에는 기본 리소스 파일이 없습니다. 기본 리소스 파일을 만들려면 여기를 클릭하십시오.**를 클릭합니다.

    Visual Studio에서 리소스 파일을 만들어 디자이너에서 엽니다.

  3. 디자이너의 맨 위에 있는 추가 단추의 드롭다운 화살표를 클릭한 다음 새 아이콘 추가를 클릭합니다.

  4. 새 아이콘 이름으로 WebPartsNode를 입력하고 추가를 클릭합니다.

    새 아이콘이 이미지 편집기에서 열립니다.

  5. 디자인을 쉽게 인식할 수 있도록 16x16 버전의 아이콘 파일을 편집합니다.

  6. 32x32 버전의 아이콘을 클릭합니다.

  7. 이미지 메뉴에서 이미지 형식 삭제를 클릭합니다.

  8. 3-7단계를 반복하여 프로젝트 리소스에 둘째 아이콘을 추가합니다. 이 아이콘의 이름을 WebPart로 지정합니다.

  9. 솔루션 탐색기에서 WebPartNodeExtension 프로젝트의 리소스 폴더 아래에 있는 WebPartsNode.ico를 선택합니다.

  10. 속성 창에서 빌드 작업 옆에 있는 드롭다운을 클릭한 다음 포함 리소스를 선택합니다.

  11. WebPart.ico에 대해 마지막 두 단계를 반복합니다.

서버 탐색기에 웹 파트 갤러리 노드 추가

각 SharePoint 사이트 노드에 새 웹 파트 갤러리 노드를 추가하는 클래스를 만듭니다. 새 코드를 추가하기 위해 클래스에서 IExplorerNodeTypeExtension 인터페이스를 구현합니다. 노드에 새 자식 노드 추가 등 서버 탐색기에서 기존 노드의 동작을 확장하려는 경우 이 인터페이스를 구현합니다.

서버 탐색기에 웹 파트 갤러리 노드를 추가하려면

  1. WebPartNodeExtension 프로젝트에서 SiteNodeExtension 코드 파일을 두 번 클릭합니다.

  2. 이 파일에 다음 코드를 붙여 넣습니다.

    참고

    이 코드를 추가하면 프로젝트에서 컴파일 오류가 발생합니다. 이러한 오류는 이후 단계에서 코드를 추가하면 사라집니다.

    Imports System.Collections.Generic
    Imports System.ComponentModel.Composition
    Imports Microsoft.SharePoint.Client
    Imports Microsoft.VisualStudio.SharePoint
    Imports Microsoft.VisualStudio.SharePoint.Explorer
    
    Namespace ServerExplorer.SharePointConnections.WebPartNode
    
        ' Export attribute: Enables Visual Studio to discover and load this extension.
        ' ExplorerNodeType attribute: Indicates that this class extends SharePoint site nodes in Server Explorer.
        ' SiteNodeExtension class: Represents an extension of SharePoint site nodes in Server Explorer.
        <Export(GetType(IExplorerNodeTypeExtension))> _
        <ExplorerNodeType(ExplorerNodeTypes.SiteNode)> _
        Friend Class SiteNodeExtension
            Implements IExplorerNodeTypeExtension
    
            Private siteUrl As System.Uri = Nothing
    
            Private Sub Initialize(ByVal nodeType As IExplorerNodeType) _
                Implements IExplorerNodeTypeExtension.Initialize
    
                ' The NodeChildrenRequested event is raised when the user expands the
                ' SharePoint site node in Server Explorer.
                AddHandler nodeType.NodeChildrenRequested, AddressOf NodeChildrenRequested
            End Sub
    
            ' Creates the new Web Part Gallery node with the specified icon.
            Private Sub NodeChildrenRequested(ByVal Sender As Object, ByVal e As ExplorerNodeEventArgs)
    
                ' Get the site URL so that it can be used later to access the site
                ' by using the SharePoint client object model.
                siteUrl = e.Node.Context.SiteUrl
    
                ' The CreateWebPartNodes argument is a delegate that Visual Studio calls 
                ' to create the child nodes under the Web Part Gallery node.
                e.Node.ChildNodes.AddFolder("Web Part Gallery", My.Resources.WebPartsNode.ToBitmap(), _
                    AddressOf CreateWebPartNodes)
            End Sub
    
            ' Creates individual Web Part nodes under the new Web Part Gallery node.
            Private Sub CreateWebPartNodes(ByVal parentNode As IExplorerNode)
    
                ' Use the SharePoint client object model to get items from the Web Part gallery.
                Dim Context As ClientContext = New ClientContext(siteUrl.AbsoluteUri)
                Dim WebPartsGallery As List = Context.Web.GetCatalog(CType(ListTemplateType.WebPartCatalog, Integer))
                Dim WebParts As ListItemCollection = WebPartsGallery.GetItems(New CamlQuery())
    
                ' Request the FieldValuesAsText property values with the Web Part items.
                Context.Load(WebParts, Function(listItems) listItems.Include(Function(i) i.FieldValuesAsText))
                Context.ExecuteQuery()
    
                If WebParts IsNot Nothing Then
                    For Each WebPart As ListItem In WebParts
    
                        ' Create a new annotation object to store the current Web Part item with the new node.
                        Dim Annotations = New Dictionary(Of Object, Object)()
                        Annotations.Add(GetType(ListItem), WebPart)
    
                        ' Create the new node for the current Web Part item.
                        parentNode.ChildNodes.Add(WebPartNodeTypeProvider.WebPartNodeTypeId, _
                            WebPart.FieldValuesAsText.FieldValues("Title"), Annotations)
                    Next
                End If
            End Sub
        End Class
    End Namespace
    
    using System.Collections.Generic;
    using System.ComponentModel.Composition;
    using Microsoft.SharePoint.Client;
    using Microsoft.VisualStudio.SharePoint;
    using Microsoft.VisualStudio.SharePoint.Explorer;
    
    namespace ServerExplorer.SharePointConnections.WebPartNode
    {
        // Enables Visual Studio to discover and load this extension.
        [Export(typeof(IExplorerNodeTypeExtension))]        
    
        // Indicates that this class extends SharePoint site nodes in Server Explorer.
        [ExplorerNodeType(ExplorerNodeTypes.SiteNode)]
    
        // Represents an extension of SharePoint site nodes in Server Explorer.
        internal class SiteNodeExtension : IExplorerNodeTypeExtension
        {
            private System.Uri siteUrl = null;
    
            public void Initialize(IExplorerNodeType nodeType)
            {
                // The NodeChildrenRequested event is raised when the user expands the
                // SharePoint site node in Server Explorer.
                nodeType.NodeChildrenRequested += NodeChildrenRequested;
            }
    
            // Creates the new Web Part Gallery node with the specified icon.
            private void NodeChildrenRequested(object sender, ExplorerNodeEventArgs e)
            {
                // Get the site URL so that it can be used later to access the site
                // by using the SharePoint client object model.
                siteUrl = e.Node.Context.SiteUrl;
    
                // The CreateWebPartNodes argument is a delegate that Visual Studio calls 
                // to create the child nodes under the Web Part Gallery node.
                e.Node.ChildNodes.AddFolder("Web Part Gallery", Properties.Resources.WebPartsNode.ToBitmap(), 
                    CreateWebPartNodes);
            }
    
            // Creates individual Web Part nodes under the new Web Part Gallery node.
            private void CreateWebPartNodes(IExplorerNode parentNode)
            {
                // Use the SharePoint client object model to get items from the Web Part gallery.
                ClientContext context = new ClientContext(siteUrl.AbsoluteUri);
                List webPartsGallery = context.Web.GetCatalog((int)ListTemplateType.WebPartCatalog);
                ListItemCollection webParts = webPartsGallery.GetItems(new CamlQuery());
    
                // Request the FieldValuesAsText property values with the Web Part items.
                context.Load(webParts, listItems => listItems.Include(i => i.FieldValuesAsText));
                context.ExecuteQuery();
    
                if (webParts != null)
                {
                    foreach (ListItem webPart in webParts)
                    {
                        // Create a new annotation object to store the current Web Part item with the new node.
                        var annotations = new Dictionary<object, object>() 
                        { 
                            { typeof(ListItem), webPart } 
                        };
    
                        // Create the new node for the current Web Part item.
                        parentNode.ChildNodes.Add(WebPartNodeTypeProvider.WebPartNodeTypeId,
                            webPart.FieldValuesAsText.FieldValues["Title"], annotations);
                    }
                }
            }
        }
    }
    

웹 파트를 나타내는 노드 형식 정의

웹 파트를 나타내는 새 노드 형식을 정의하는 클래스를 만듭니다. 새 노드 형식은 Visual Studio에서 웹 파트 갤러리 노드 아래에 자식 노드를 표시하는 데 사용됩니다. 이러한 각 자식 노드는 SharePoint 사이트에서 하나의 웹 파트를 나타냅니다.

새 노드 형식을 정의하기 위해 클래스에서 IExplorerNodeTypeProvider 인터페이스를 구현합니다. 서버 탐색기에서 새 노드 형식을 정의하려는 경우 이 인터페이스를 구현합니다.

웹 파트 노드 형식을 정의하려면

  1. WebPartNodeExtension 프로젝트에서 WebPartNodeTypeProvider 코드 파일을 두 번 클릭합니다.

  2. 이 파일에 다음 코드를 붙여 넣습니다.

    Imports System
    Imports System.Collections.Generic
    Imports System.Windows.Forms
    Imports System.ComponentModel.Composition
    Imports Microsoft.SharePoint.Client
    Imports Microsoft.VisualStudio.SharePoint
    Imports Microsoft.VisualStudio.SharePoint.Explorer
    
    Namespace ServerExplorer.SharePointConnections.WebPartNode
    
        ' Export attribute: Enables Visual Studio to discover and load this extension.
        ' ExplorerNodeType attribute: Specifies the ID for this new node type.
        ' WebPartNodeTypeProvider class: Defines a new node type that represents a Web Part on a SharePoint site.
        <Export(GetType(IExplorerNodeTypeProvider))> _
        <ExplorerNodeType(WebPartNodeTypeProvider.WebPartNodeTypeId)> _
        Friend Class WebPartNodeTypeProvider
            Implements IExplorerNodeTypeProvider
    
            Friend Const WebPartNodeTypeId As String = "Contoso.WebPart"
    
            Private Sub InitializeType(ByVal typeDefinition As IExplorerNodeTypeDefinition) _
            Implements IExplorerNodeTypeProvider.InitializeType
                typeDefinition.DefaultIcon = My.Resources.WebPart.ToBitmap()
                typeDefinition.IsAlwaysLeaf = True
    
                AddHandler typeDefinition.NodePropertiesRequested, AddressOf NodePropertiesRequested
                AddHandler typeDefinition.NodeMenuItemsRequested, AddressOf NodeMenuItemsRequested
            End Sub
    
            ' Retrieves properties that are displayed in the Properties window when
            ' a Web Part node is selected.
            Private Sub NodePropertiesRequested(ByVal Sender As Object, _
                ByVal e As ExplorerNodePropertiesRequestedEventArgs)
    
                Dim webPart = e.Node.Annotations.GetValue(Of ListItem)()
                Dim propertySource = e.Node.Context.CreatePropertySourceObject( _
                    webPart.FieldValuesAsText.FieldValues)
                e.PropertySources.Add(propertySource)
            End Sub
    
            Private Sub NodeMenuItemsRequested(ByVal Sender As Object, _
                ByVal e As ExplorerNodeMenuItemsRequestedEventArgs)
                Dim WebPartNodeMenuItem As IMenuItem = e.MenuItems.Add("Display Message")
                AddHandler WebPartNodeMenuItem.Click, AddressOf MenuItemClick
            End Sub
    
            Private Sub MenuItemClick(ByVal Sender As Object, ByVal e As MenuItemEventArgs)
                Dim ParentNode As IExplorerNode = TryCast(e.Owner, IExplorerNode)
                If ParentNode IsNot Nothing Then
                    Dim webPart = ParentNode.Annotations.GetValue(Of ListItem)()
                    MessageBox.Show("You clicked the context menu for the following Web part: " & _
                        webPart.FieldValuesAsText.FieldValues("Title") + ".", "Web Part Menu Command")
                End If
            End Sub
        End Class
    End Namespace
    
    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;
    using System.ComponentModel.Composition;
    using Microsoft.SharePoint.Client;
    using Microsoft.VisualStudio.SharePoint;
    using Microsoft.VisualStudio.SharePoint.Explorer;
    
    namespace ServerExplorer.SharePointConnections.WebPartNode
    {
        // Enables Visual Studio to discover and load this extension.
        [Export(typeof(IExplorerNodeTypeProvider))]
    
        // Specifies the ID for this new node type.
        [ExplorerNodeType(WebPartNodeTypeProvider.WebPartNodeTypeId)]
    
        // Defines a new node type that represents a Web Part on a SharePoint site.
        internal class WebPartNodeTypeProvider : IExplorerNodeTypeProvider
        {
            internal const string WebPartNodeTypeId = "Contoso.WebPart";
    
            public void InitializeType(IExplorerNodeTypeDefinition typeDefinition)
            {
                typeDefinition.DefaultIcon = Properties.Resources.WebPart.ToBitmap();
                typeDefinition.IsAlwaysLeaf = true;
    
                typeDefinition.NodePropertiesRequested += NodePropertiesRequested;
                typeDefinition.NodeMenuItemsRequested += NodeMenuItemsRequested;
            }
    
            // Retrieves properties that are displayed in the Properties window when
            // a Web Part node is selected.
            private void NodePropertiesRequested(object sender,
                ExplorerNodePropertiesRequestedEventArgs e)
            {
                var webPart = e.Node.Annotations.GetValue<ListItem>();
                object propertySource = e.Node.Context.CreatePropertySourceObject(
                    webPart.FieldValuesAsText.FieldValues);
                e.PropertySources.Add(propertySource);
            }
    
            private void NodeMenuItemsRequested(
                object sender, ExplorerNodeMenuItemsRequestedEventArgs e)
            {
                e.MenuItems.Add("Display Message").Click += MenuItemClick;
            }
    
            private void MenuItemClick(object sender, MenuItemEventArgs e)
            {
                IExplorerNode parentNode = e.Owner as IExplorerNode;
    
                if (parentNode != null)
                {
                    var webPart = parentNode.Annotations.GetValue<ListItem>();
                    MessageBox.Show("You clicked the context menu for the following Web part: " +
                        webPart.FieldValuesAsText.FieldValues["Title"] + ".", "Web Part Menu Command");
                }
            }
        }
    }
    

검사점

이 연습의 이전 단계를 통해 웹 파트 갤러리 노드를 위한 모든 코드가 프로젝트에 포함되었습니다. 솔루션을 빌드하여 프로젝트가 오류 없이 컴파일되는지 확인합니다.

솔루션을 빌드하려면

  • 빌드 메뉴에서 솔루션 빌드를 선택합니다.

확장을 배포하기 위한 VSIX 패키지 만들기

확장을 배포하려면 솔루션에서 VSIX 프로젝트를 사용하여 VSIX 패키지를 만듭니다. 먼저 프로젝트에 포함된 source.extension.vsixmanifest 파일을 수정하여 VSIX 패키지를 구성합니다. 그런 다음 솔루션을 빌드하여 VSIX 패키지를 만듭니다.

VSIX 패키지를 구성하려면

  1. 솔루션 탐색기WebPartNode 프로젝트에서 WebPartNode 프로젝트의 source.extension.vsixmanifest 파일을 두 번 클릭합니다.

    매니페스트 편집기에서 파일이 열립니다. source.extension.vsixmanifest 파일은 모든 VSIX 패키지에 필요한 extension.vsixmanifest 파일의 기초를 제공합니다. 이 파일에 대한 자세한 내용은 VSIX Extension Schema Reference를 참조하십시오.

  2. 제품 이름 상자에 Web Part Gallery Node for Server Explorer를 입력합니다.

  3. 만든 이 상자에 Contoso를 입력합니다.

  4. 설명 상자에 서버 탐색기의 SharePoint 연결 노드에 사용자 지정 웹 파트 갤러리 노드를 추가합니다.를 입력합니다.

  5. 편집기의 콘텐츠 섹션에서 콘텐츠 추가 단추를 클릭합니다.

  6. 콘텐츠 추가 대화 상자의 콘텐츠 형식 선택 목록 상자에서 MEF Component를 선택합니다.

    참고

    이 값은 extension.vsixmanifest 파일의 MefComponent 요소에 해당합니다. 이 요소는 VSIX 패키지의 확장 어셈블리 이름을 지정합니다. 자세한 내용은 MEFComponent Element (VSX Schema)를 참조하십시오.

  7. 소스 선택에서 프로젝트 라디오 단추를 클릭하고 그 옆에 있는 목록 상자에서 WebPartNodeExtension을 선택합니다.

  8. 확인을 클릭합니다.

  9. 빌드 메뉴에서 솔루션 빌드를 클릭합니다. 솔루션이 오류 없이 컴파일되는지 확인합니다.

  10. WebPartNode 프로젝트의 빌드 출력 폴더를 엽니다. 이제 이 폴더에 WebPartNode.vsix 파일이 들어 있습니다.

    기본적으로 빌드 출력 경로는 프로젝트 파일이 포함된 폴더 아래에 있는 .. \bin\Debug 폴더입니다.

확장 테스트

이제 서버 갤러리에서 새 웹 파트 갤러리 노드를 테스트할 준비가 되었습니다. 우선 실험 모드의 Visual Studio 인스턴스에서 확장 프로젝트 디버깅을 시작합니다. 그런 다음 실험 모드의 Visual Studio 인스턴스에 새 웹 파트 노드를 사용합니다.

확장 디버깅을 시작하려면

  1. 관리자 권한으로 Visual Studio를 다시 시작하고 WebPartNode 솔루션을 엽니다.

  2. WebPartNodeExtension 프로젝트에서 SiteNodeExtension 코드 파일을 열고 NodeChildrenRequested 및 CreateWebPartNodes 메서드의 코드 첫 줄에 중단점을 추가합니다.

  3. F5 키를 눌러 디버깅을 시작합니다.

    Visual Studio에서는 확장을 %UserProfile%\AppData\Local\Microsoft\VisualStudio\10.0Exp\Extensions\Contoso\Web Part Gallery Node Extension for Server Explorer\1.0에 설치하고 실험 모드의 Visual Studio 인스턴스를 시작합니다. 이 Visual Studio 인스턴스에서 프로젝트 항목을 테스트합니다.

확장을 테스트하려면

  1. 실험 모드의 Visual Studio 인스턴스에서 보기 메뉴의 서버 탐색기를 클릭합니다.

  2. 테스트에 사용할 SharePoint 사이트가 서버 탐색기SharePoint 연결 노드 아래에 표시되는지 확인합니다. 해당 사이트가 표시되지 않으면 다음 단계를 수행합니다.

    1. SharePoint 연결을 마우스 오른쪽 단추로 클릭한 다음 연결 추가를 클릭합니다.

    2. SharePoint 연결 추가 대화 상자에서 연결할 SharePoint 사이트의 URL을 입력합니다. 개발 컴퓨터의 SharePoint 사이트를 지정하려면 https://localhost를 입력합니다.

    3. 확인을 클릭합니다.

  3. 사이트 연결 노드(사이트의 URL을 표시하는 노드)를 확장한 다음 자식 사이트 노드(예: 팀 사이트)를 확장합니다.

  4. 다른 Visual Studio 인스턴스의 코드가 이전에 NodeChildrenRequested 메서드에 설정한 중단점에서 중지하는지 확인합니다. F5 키를 눌러 프로젝트를 계속 디버깅합니다.

  5. 실험 모드의 Visual Studio 인스턴스에서 웹 파트 갤러리라는 새 노드가 최상위 사이트 노드 아래에 표시되는지 확인합니다. 웹 파트 갤러리 노드를 확장합니다.

  6. 다른 Visual Studio 인스턴스의 코드가 이전에 CreateWebPartNodes 메서드에 설정한 중단점에서 중지하는지 확인합니다. F5 키를 눌러 프로젝트를 계속 디버깅합니다.

  7. 실험 모드의 Visual Studio 인스턴스에서 연결된 사이트의 모든 웹 파트가 서버 탐색기웹 파트 갤러리 노드 아래에 표시되는지 확인합니다.

  8. 웹 파트 중 하나를 마우스 오른쪽 단추로 클릭하고 속성을 클릭합니다.

  9. 속성 창에 표시되는 웹 파트의 세부 정보를 확인합니다.

  10. 서버 탐색기에서 동일한 웹 파트를 다시 마우스 오른쪽 단추로 클릭한 다음 메시지 표시를 클릭합니다.

    메시지 상자가 표시되는지 확인합니다. 메시지 상자에서 확인을 클릭합니다.

Visual Studio에서 확장 제거

확장 테스트를 마친 후 Visual Studio에서 확장을 제거합니다.

확장을 제거하려면

  1. 실험 모드의 Visual Studio 인스턴스에서 도구 메뉴의 확장 관리자를 클릭합니다.

    확장 관리자 대화 상자가 열립니다.

  2. 확장 목록에서 Web Part Gallery Node Extension for Server Explorer를 클릭한 다음 제거를 클릭합니다.

  3. 나타나는 대화 상자에서 를 클릭하여 확장을 제거합니다.

  4. 지금 다시 시작을 클릭하여 제거를 완료합니다. 프로젝트 항목도 제거됩니다.

  5. Visual Studio의 두 인스턴스, 즉 실험 모드의 인스턴스와 WebPartNode 솔루션이 열려 있는 Visual Studio 인스턴스를 모두 닫습니다.

참고 항목

작업

연습: 서버 탐색기를 확장하여 웹 파트 표시

새 비트맵 또는 다른 이미지 만들기

참조

이미지 편집기

개념

SharePoint 개체 모델 호출

기타 리소스

서버 탐색기에서 SharePoint 연결 노드 확장