SPContentType.Parent-Eigenschaft

Ruft der übergeordneten Inhaltstyp dieses Inhaltstyps geben.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public ReadOnly Property Parent As SPContentType
    Get
'Usage
Dim instance As SPContentType
Dim value As SPContentType

value = instance.Parent
public SPContentType Parent { get; }

Eigenschaftswert

Typ: Microsoft.SharePoint.SPContentType
Der übergeordnete Inhaltstyp.

Hinweise

Der Wert dieser Eigenschaft ist der Inhaltstyp aus dem aktuelle Inhaltstyp abgeleitet wurde.

Beispiele

Das folgende Beispiel ist eine Konsolenanwendung, die das Erbe des Inhaltstyps integrierten Announcement untersucht. Im Beispiel ruft einen Verweis auf den Inhaltstyp, verwendet diese Referenz, um einen Verweis auf seinem übergeordneten Inhaltstyp erhalten und verwendet diese Referenz, um einen Verweis auf das übergeordnete übergeordneten Inhaltstyp (in diesem Fall System) zu erhalten. Die Anwendung dann absteigend die Hierarchie, von dem Wert eines jeden Inhaltstyp Name und Id -Eigenschaft in der Konsole angezeigt.

Imports System
Imports Microsoft.SharePoint

Module ConsoleApp

    Sub Main()
        Console.WriteLine()

        Dim oSPSite As SPSite = New SPSite("https://localhost")
        Dim oSPWeb As SPWeb = oSPSite.OpenWeb()

        Dim child As SPContentType = oSPWeb.AvailableContentTypes(SPBuiltInContentTypeId.Announcement)
        Dim parent As SPContentType = child.Parent
        Dim grandparent As SPContentType = parent.Parent

        Console.WriteLine(grandparent.Name + "        " + grandparent.Id.ToString())
        Console.WriteLine(parent.Name + "          " + parent.Id.ToString())
        Console.WriteLine(child.Name + "  " + child.Id.ToString())

        oSPWeb.Dispose()
        oSPSite.Dispose()

        Console.WriteLine()
        Console.Write("Press ENTER to continue...")
        Console.ReadLine()
    End Sub

End Module
using System;
using Microsoft.SharePoint;

namespace Test
{
    class ConsoleApp
    {
        static void Main(string[] args)
        {
            Console.WriteLine();
            SPSite oSPSite = new SPSite("https://localhost");
            SPWeb oSPWeb = oSPSite.OpenWeb();

            SPContentType child = oSPWeb.AvailableContentTypes[SPBuiltInContentTypeId.Announcement];
            SPContentType parent = child.Parent;
            SPContentType grandparent = parent.Parent;

            Console.WriteLine(grandparent.Name + "        " + grandparent.Id.ToString());
            Console.WriteLine(parent.Name + "          " + parent.Id.ToString());
            Console.WriteLine(child.Name + "  " + child.Id.ToString());

            oSPWeb.Dispose();
            oSPSite.Dispose();

            Console.WriteLine();
            Console.Write("Press ENTER to continue...");
            Console.ReadLine();
        }
    }
}

Die Beispielanwendung druckt die folgende Ausgabe wird in der Konsole angezeigt.

System        0x
Item          0x01
Announcement  0x0104

Press ENTER to continue...

Siehe auch

Referenz

SPContentType Klasse

SPContentType-Member

Microsoft.SharePoint-Namespace

Weitere Ressourcen

Introduction to Content Types

Site and List Content Types

Base Content Type Hierarchy