Share via


de la propiedad SPContentType.Id

Obtiene un objeto SPContentTypeId que representa el identificador de tipo de contenido (ID.) del tipo de contenido.

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

Sintaxis

'Declaración
Public ReadOnly Property Id As SPContentTypeId
    Get
'Uso
Dim instance As SPContentType
Dim value As SPContentTypeId

value = instance.Id
public SPContentTypeId Id { get; }

Valor de propiedad

Tipo: Microsoft.SharePoint.SPContentTypeId
El identificador de tipo de contenido.

Comentarios

Identificadores de tipo de contenido identifican tipos de contenido y están diseñados para ser recursiva. El identificador de tipo de contenido encapsula linaje de dicho 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 de ese tipo de contenido primario etc., en última instancia a e incluidos el contenido del sistema, escriba Id. Analizando el identificador de tipo de contenido, puede determinar qué tipos de contenido hereda el tipo de contenido y cómo dos tipos de contenido están relacionadas.

Para obtener más información, vea Content Type IDs.

Ejemplos

En el siguiente ejemplo es una aplicación de consola que busca un sitio para las listas que tienen el tipo de contenido de documento integrado en su colección de tipo de contenido. Cuando se encuentra una coincidencia, la aplicación imprime el identificador de tipo de contenido primario y el identificador de tipo de contenido correspondiente a la consola.

Imports System
Imports Microsoft.SharePoint

Module Test
   Sub Main()
      Using site As SPSite = New SPSite("https://localhost")
         Using web As SPWeb = site.OpenWeb()

            ' Search for a built-in content type on lists in the site.
            Dim parentId As SPContentTypeId = SPBuiltInContentTypeId.Document

            For Each list As SPList In web.Lists
               Dim matchId As SPContentTypeId = _
                  list.ContentTypes.BestMatch(parentId)
               ' Report a match only if the list is not hidden
               ' (e.g. Master Page Gallery).
               If parentId.IsParentOf(matchId) And Not list.Hidden Then
                  Console.WriteLine("{0} has the {1} content type.", _
                                     list.Title, _
                                     list.ContentTypes(matchId).Name)
                  Console.WriteLine("parent content type id: {0}", _
                                     parentId.ToString())
                  Console.WriteLine("  list content type id: {0}",_
                                     matchId.ToString())
               End If
            Next list
         End Using
      End Using
      Console.Write(vbCrLf + "Press ENTER to continue...")
      Console.ReadLine()
   End Sub
End Module
using System;
using Microsoft.SharePoint;

namespace Test
{
   class ConsoleApp
   {
      static void Main(string[] args)
      {
         using (SPSite site = new SPSite("https://localhost"))
         {
            using (SPWeb web = site.OpenWeb())
            {
               // Search for a built-in content type on lists in the site.
               SPContentTypeId parentId = SPBuiltInContentTypeId.Document;
               foreach (SPList list in web.Lists)
               {
                  SPContentTypeId matchId = 
                     list.ContentTypes.BestMatch(parentId);
                  // Report a match only if the list is not hidden 
                  // (e.g. Master Page Gallery).
                  if (parentId.IsParentOf(matchId) && !list.Hidden)
                  {
                     Console.WriteLine("{0} has the {1} content type.",
                                        list.Title, 
                                        list.ContentTypes[matchId].Name);
                     Console.WriteLine("parent content type id: {0}",
                                        parentId.ToString());
                     Console.WriteLine("  list content type id: {0}", 
                                        matchId.ToString());
                  }
               }
            }
         }
         Console.Write("\nPress ENTER to continue...");
         Console.ReadLine();
      }
   }
}

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

Shared Documents has the Document content type.
parent content type id: 0x0101
  list content type id: 0x010100C21DAAD3BCD4FF409A4DB5005BF7E12F

Press ENTER to continue...

Vea también

Referencia

clase SPContentType

Miembros SPContentType

Espacio de nombres Microsoft.SharePoint

Otros recursos

Content Type IDs

Introduction to Content Types

Site and List Content Types

Base Content Type Hierarchy