Aracılığıyla paylaş


Nasıl yapılır: Server Explorer'a özel SharePoint düğümü ekleme

Altında özel düğümler ekleyebilirsiniz SharePoint bağlantıları düğümünde Server Explorer.Olarak görüntülenmeyen ek SharePoint bileşenleri görüntülemek istediğinizde yararlıdır Server Explorer varsayılan olarak.Daha fazla bilgi için bkz. Server Explorer'da SharePoint bağlantı düğümü genişletme.

Özel düğüm eklemek için önce yeni düğüm tanımlayan bir sınıf oluşturun.Daha sonra düğüm varolan bir düğümün alt düğümü ekleyen bir uzantısı oluşturun.

Yeni düğüm tanımlamak için

  1. Bir class library projesi oluşturun.

  2. Aşağıdaki derlemeler başvurular ekleyin:

    • Microsoft.VisualStudio.SharePoint

    • Microsoft.VisualStudio.SharePoint.Explorer.Extensions

    • System.ComponentModel.Composition

    • System.Drawing

  3. IExplorerNodeTypeProvider arabirimini uygulayan bir sınıf oluşturun.

  4. Aşağıdaki öznitelikler sınıfına ekleyin:

  5. Uygulamanız içinde IExplorerNodeTypeProvider.InitializeType yöntemi, kullanım üyeleri typeDefinition parametresi yeni düğüm davranışını yapılandırmak için.Bu parametre bir IExplorerNodeTypeDefinition tanımlanan olayları erişim sağlayan nesne IExplorerNodeEvents arabirimi.

    Aşağıdaki kod örneği, yeni bir düğümü tanımlamak gösterilmiştir.Bu örnek, projenizi katıştırılmış bir kaynak olarak CustomChildNodeIcon adlı bir simge içerir varsayar.

    <Export(GetType(IExplorerNodeTypeProvider))> _
    <ExplorerNodeType(ExampleNodeTypeProvider.NodeTypeId)> _
    Friend Class ExampleNodeTypeProvider
        Implements IExplorerNodeTypeProvider
        Friend Const NodeTypeId As String = "Contoso.ServerExplorerNodeExample"
    
        Private Sub InitializeType(ByVal typeDefinition As IExplorerNodeTypeDefinition) _
            Implements IExplorerNodeTypeProvider.InitializeType
            typeDefinition.DefaultIcon = _
                My.Resources.CustomChildNodeIcon.ToBitmap()
            typeDefinition.IsAlwaysLeaf = True
        End Sub
    End Class
    
    [Export(typeof(IExplorerNodeTypeProvider))]
    [ExplorerNodeType(ExampleNodeTypeProvider.NodeTypeId)]
    internal class ExampleNodeTypeProvider : IExplorerNodeTypeProvider
    {
        internal const string NodeTypeId = "Contoso.ServerExplorerNodeExample";
    
        public void InitializeType(IExplorerNodeTypeDefinition typeDefinition)
        {
            typeDefinition.DefaultIcon =
                Properties.Resources.CustomChildNodeIcon.ToBitmap();
            typeDefinition.IsAlwaysLeaf = true;
        }
    }
    

Yeni düğüm varolan bir düğümün alt düğümü eklemek için

  1. Düğüm tanımınızı aynı projede uygulayan bir sınıf oluşturmak IExplorerNodeTypeExtension arabirimi.

  2. Ekleme System.ComponentModel.Composition.ExportAttribute class özniteliği.Bu öznitelik bulmak ve yüklemek Visual Studio sağlar, IExplorerNodeTypeExtension uygulaması.PASS IExplorerNodeTypeExtension türü öznitelik Oluşturucusu.

  3. Ekleme ExplorerNodeTypeAttribute class özniteliği.Bir düğüm uzantısı ile bu öznitelik, genişletmek istediğiniz düğüm türü dize tanımlayıcısını belirtir.

    Visual Studio tarafından sağlanan yerleşik düğüm türlerini belirtmek için aşağıdaki numaralandırma değerlerden birini özniteliği kurucusuna aktarmalısınız:

    • ExplorerNodeTypes: Site bağlantı düğümleri (sitesi URL'lerini görüntüleme düğümler) belirtmek için bu değerleri düğümleri veya diğer tüm üst düğümler site kullanım Server Explorer.

    • ExtensionNodeTypes: Bir SharePoint sitesinde liste, alan veya içerik türünü temsil eden bir düğüm gibi tek bir bileşeni temsil eden yerleşik düğümlerden birini belirtmek için bu değerleri kullanın.

  4. Uygulamanız içinde Initialize yöntemi, tanıtıcı NodeChildrenRequested , olay IExplorerNodeType parametresi.

  5. De NodeChildrenRequested olay işleyicisi alt düğümler topluluğu için yeni düğüm ekleme Node olay bağımsız parametresi tarafından kullanıma sunulan nesne.

    SharePoint sitesini düğümün alt düğümü olarak yeni düğüm ekleme aşağıdaki kod örneği göstermektedir Server Explorer.

    <Export(GetType(IExplorerNodeTypeExtension))> _
    <ExplorerNodeType(ExplorerNodeTypes.SiteNode)> _
    Friend Class SiteNodeExtension
        Implements IExplorerNodeTypeExtension
    
        Private Sub Initialize(ByVal nodeType As IExplorerNodeType) _
            Implements IExplorerNodeTypeExtension.Initialize
            AddHandler nodeType.NodeChildrenRequested, AddressOf NodeChildrenRequested
        End Sub
    
        Private Sub NodeChildrenRequested(ByVal Sender As Object, ByVal e As ExplorerNodeEventArgs)
            e.Node.ChildNodes.Add(ExampleNodeTypeProvider.NodeTypeId, _
                "Custom Node", Nothing)
        End Sub
    End Class
    
    [Export(typeof(IExplorerNodeTypeExtension))]
    [ExplorerNodeType(ExplorerNodeTypes.SiteNode)]
    internal class SiteNodeExtension : IExplorerNodeTypeExtension
    {
        public void Initialize(IExplorerNodeType nodeType)
        {
            nodeType.NodeChildrenRequested += NodeChildrenRequested;
        }
    
        private void NodeChildrenRequested(object sender, ExplorerNodeEventArgs e)
        {
            e.Node.ChildNodes.Add(ExampleNodeTypeProvider.NodeTypeId,
                "Custom Node", null);
        }
    }
    

Tam Örnek

Aşağıdaki kod örneği, basit bir düğümü tanımlamak ve eklemek, SharePoint sitesi düğümün alt düğümü olarak tam kodu sağlar Server Explorer.

Imports System.ComponentModel.Composition
Imports Microsoft.VisualStudio.SharePoint
Imports Microsoft.VisualStudio.SharePoint.Explorer

Namespace Contoso.ServerExplorerExtension

    <Export(GetType(IExplorerNodeTypeProvider))> _
    <ExplorerNodeType(ExampleNodeTypeProvider.NodeTypeId)> _
    Friend Class ExampleNodeTypeProvider
        Implements IExplorerNodeTypeProvider
        Friend Const NodeTypeId As String = "Contoso.ServerExplorerNodeExample"

        Private Sub InitializeType(ByVal typeDefinition As IExplorerNodeTypeDefinition) _
            Implements IExplorerNodeTypeProvider.InitializeType
            typeDefinition.DefaultIcon = _
                My.Resources.CustomChildNodeIcon.ToBitmap()
            typeDefinition.IsAlwaysLeaf = True
        End Sub
    End Class

    <Export(GetType(IExplorerNodeTypeExtension))> _
    <ExplorerNodeType(ExplorerNodeTypes.SiteNode)> _
    Friend Class SiteNodeExtension
        Implements IExplorerNodeTypeExtension

        Private Sub Initialize(ByVal nodeType As IExplorerNodeType) _
            Implements IExplorerNodeTypeExtension.Initialize
            AddHandler nodeType.NodeChildrenRequested, AddressOf NodeChildrenRequested
        End Sub

        Private Sub NodeChildrenRequested(ByVal Sender As Object, ByVal e As ExplorerNodeEventArgs)
            e.Node.ChildNodes.Add(ExampleNodeTypeProvider.NodeTypeId, _
                "Custom Node", Nothing)
        End Sub
    End Class
End Namespace
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.SharePoint;
using Microsoft.VisualStudio.SharePoint.Explorer;

namespace Contoso.ServerExplorerExtension
{
    [Export(typeof(IExplorerNodeTypeProvider))]
    [ExplorerNodeType(ExampleNodeTypeProvider.NodeTypeId)]
    internal class ExampleNodeTypeProvider : IExplorerNodeTypeProvider
    {
        internal const string NodeTypeId = "Contoso.ServerExplorerNodeExample";

        public void InitializeType(IExplorerNodeTypeDefinition typeDefinition)
        {
            typeDefinition.DefaultIcon =
                Properties.Resources.CustomChildNodeIcon.ToBitmap();
            typeDefinition.IsAlwaysLeaf = true;
        }
    }

    [Export(typeof(IExplorerNodeTypeExtension))]
    [ExplorerNodeType(ExplorerNodeTypes.SiteNode)]
    internal class SiteNodeExtension : IExplorerNodeTypeExtension
    {
        public void Initialize(IExplorerNodeType nodeType)
        {
            nodeType.NodeChildrenRequested += NodeChildrenRequested;
        }

        private void NodeChildrenRequested(object sender, ExplorerNodeEventArgs e)
        {
            e.Node.ChildNodes.Add(ExampleNodeTypeProvider.NodeTypeId,
                "Custom Node", null);
        }
    }
}

Kod Derleniyor

Bu örnek, projenizi katıştırılmış bir kaynak olarak CustomChildNodeIcon adlı bir simge içerir varsayar.Bu örnek ayrıca aşağıdaki derlemelerine başvurular gerektirir:

  • Microsoft.VisualStudio.SharePoint

  • System.ComponentModel.Composition

  • System.Drawing

Uzantısı dağıtma

Dağıtmak için Server Explorer uzantısı oluşturmak bir Visual Studio uzantısı (VSIX) paketini derleme ve uzantısıyla dağıtmak istediğiniz diğer dosyaları.Daha fazla bilgi için bkz. Visual Studio SharePoint Araçlar için uzantıları dağıtma.

Ayrıca bkz.

Görevler

İzlenecek yol: Server Explorer'da görünen Web bölümlerini genişletme

Kavramlar

Nasıl yapılır: Server Explorer'da SharePoint düğümü genişletme

Diğer Kaynaklar

Server Explorer'da SharePoint bağlantı düğümü genişletme