Share via


Estructura SPContentTypeId

Representa el identificador (ID.) de un tipo de contenido.

Espacio de nombres:  Microsoft.SharePoint
Ensamblado:  Microsoft.SharePoint (en Microsoft.SharePoint.dll)

Sintaxis

'Declaración
<SerializableAttribute> _
Public Structure SPContentTypeId _
    Implements IComparable
'Uso
Dim instance As SPContentTypeId
[SerializableAttribute]
public struct SPContentTypeId : IComparable

Comentarios

Identificadores de tipo de contenido identificar exclusivamente el tipo de contenido y están diseñados para ser recursiva. El identificador de tipo de contenido encapsula el linaje de un tipo de contenido o la línea de los tipos de contenido primario desde el que se hereda del tipo de contenido. Cada identificador de tipo de contenido contiene el identificador del tipo de contenido de primario, que a su vez contiene el identificador del elemento primario de dicho tipo de contenido y así sucesivamente, en última instancia a e incluido el contenido de System tipo de identificador.

For more information, see Content Type IDs and the Id property.

Ejemplos

El ejemplo siguiente muestra una aplicación de consola que rellena una matriz con tipo de contenido integrada cinco identificadores y cuenta el número de descendientes que cada miembro de la matriz tiene en común con otros miembros de la matriz. También se imprime los valores de cadena en la consola.

Imports System
Imports System.Collections.Generic
Imports Microsoft.SharePoint

Module ConsoleApp

    Sub Main()

        ' Fill an array with SPContentTypeId objects.
        Dim ids As New List(Of SPContentTypeId)
        ids.Add(SPBuiltInContentTypeId.System)
        ids.Add(SPBuiltInContentTypeId.Item)
        ids.Add(SPBuiltInContentTypeId.Document)
        ids.Add(SPBuiltInContentTypeId.BasicPage)
        ids.Add(SPBuiltInContentTypeId.WebPartPage)

        ' Display the hex strings.
        Console.WriteLine("The list has {0} content type IDs:", ids.Count.ToString())
        For Each id As SPContentTypeId In ids
            Console.WriteLine("{0}", id.ToString())
        Next

        ' Show the lineage.
        Console.WriteLine()
        For i As Integer = 0 To ids.Count - 1
            Dim parent As SPContentTypeId = ids(i)
            Dim children As Integer = 0
            For j As Integer = 0 To ids.Count - 1
                Dim id As SPContentTypeId = ids(j)
                If id.IsChildOf(parent) And id <> parent Then
                    children += 1
                End If
            Next
            Console.WriteLine("{0} descendants of {1}", children.ToString(), ids(i).ToString())
        Next

        Console.Write(vbCrLf & "Press ENTER to continue....")
        Console.Read()
    End Sub
End Module
using System;
using System.Collections.Generic;
using Microsoft.SharePoint;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            // Fill an array with SPContentTypeId objects.
            List<SPContentTypeId> ids = new List<SPContentTypeId>
               { 
                  SPBuiltInContentTypeId.System,
                  SPBuiltInContentTypeId.Item,
                  SPBuiltInContentTypeId.Document, 
                  SPBuiltInContentTypeId.BasicPage, 
                  SPBuiltInContentTypeId.WebPartPage
               };

            // Display the hex strings.
            Console.WriteLine("The list has {0} content type IDs:", ids.Count.ToString());
            foreach (SPContentTypeId id in ids) Console.WriteLine("{0}", id.ToString());

            // Show the lineage.
            Console.WriteLine();
            for (int i = 0; i < ids.Count; i++)
            {
                SPContentTypeId parent = ids[i];
                int children = 0;
                for (int j = 0; j < ids.Count; j++)
                {
                    SPContentTypeId id = ids[j];
                    if (id.IsChildOf(parent) && id != parent)
                        children++;
                }
                Console.WriteLine("{0} descendants of {1}", children.ToString(), ids[i].ToString());

            }

            Console.Write("\nPress ENTER to continue....");
            Console.Read();
        }
    }
}

La aplicación imprime el siguiente resultado en la consola.

The list has 5 content type IDs:
0x
0x01
0x0101
0x010109
0x01010901

4 descendants of 0x
3 descendants of 0x01
2 descendants of 0x0101
1 descendants of 0x010109
0 descendants of 0x01010901

Press ENTER to continue...

Seguridad para subprocesos

Los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para subprocesos. No se garantiza que los miembros de instancias sean seguros para los subprocesos.

Vea también

Referencia

Miembros SPContentTypeId

Espacio de nombres Microsoft.SharePoint

Id

SPBuiltInContentTypeId

Otros recursos

Content Type IDs

Introduction to Content Types

Site and List Content Types

Base Content Type Hierarchy