SPContentType.Parent 属性
获取父内容类型的此内容类型。
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public ReadOnly Property Parent As SPContentType
Get
用法
Dim instance As SPContentType
Dim value As SPContentType
value = instance.Parent
public SPContentType Parent { get; }
属性值
类型:Microsoft.SharePoint.SPContentType
父内容类型。
备注
此属性的值是当前内容类型派生的内容类型。
示例
下面的示例是一个检查的内置Announcement内容类型继承的控制台应用程序。该示例获取对内容类型的引用,使用该引用来获取对其父内容类型的引用并使用该引用 (在本例中为System) 获取对的父对象的父内容类型的引用。应用程序然后递减层次结构,打印到控制台的每个内容类型Name和Id属性的值。
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();
}
}
}
示例应用程序打印以下输出到控制台。
System 0x
Item 0x01
Announcement 0x0104
Press ENTER to continue...