SPContentType-Konstruktor (SPContentType, SPContentTypeCollection, String)

Initialisiert eine neue Instanz der Klasse SPContentType mithilfe des angegebenen übergeordneten Inhaltstyps.

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

Syntax

'Declaration
Public Sub New ( _
    parentContentType As SPContentType, _
    collection As SPContentTypeCollection, _
    name As String _
)
'Usage
Dim parentContentType As SPContentType
Dim collection As SPContentTypeCollection
Dim name As String

Dim instance As New SPContentType(parentContentType, _
    collection, name)
public SPContentType(
    SPContentType parentContentType,
    SPContentTypeCollection collection,
    string name
)

Parameter

  • name
    Typ: System.String

    Der Name des Inhaltstyps. Diese Zeichenfolge wird als der Wert der Name -Eigenschaft in den neuen Inhaltstyp festgelegt.

Ausnahmen

Ausnahme Bedingung
SPException

Die Auflistung kann nicht geändert werden.

ArgumentException

Die SPList , auf dem sich die parentContentType befindet, ist Null .

-ODER-

Die parentContentType wurde aus der übergeordneten SPContentTypeCollectionentfernt.

Hinweise

Das Auflistung (Objekt), das Sie als zweites Argument an den Konstruktor übergeben wird verwendet, um bestimmte Anfangswerte für die Eigenschaften des neuen Inhaltstyps zu erhalten. Der neue Inhaltstyp wird jedoch nicht automatisch zur Auflistung hinzugefügt. Sie müssen diese selbst in einem nachfolgenden Aufruf der Add(SPContentType) -Methode durchführen.

Dieser Konstruktor legt den Wert des neuen Objekts Name -Eigenschaft auf den im Argument name übergebenen Wert fest.

Beispiele

Das folgende Beispiel erstellt einen Inhaltstyp an, der vom Typ "Item" abgeleitet ist und fügt dann den neuen Typ für die Websitesammlung.

Dim site As SPSite = New SPSite("https://localhost")
Dim web As SPWeb = site.OpenWeb()

' Get a reference to the site content type collection.
Dim contentTypes As SPContentTypeCollection = web.ContentTypes

' Create a Customer content type derived from the Item content type.
Dim contentType As SPContentType = New SPContentType(contentTypes("Item"), contentTypes, "Customer")

' Add the content type to the site collection.
contentType = contentTypes.Add(contentType)

' Clean up.
web.Dispose()
site.Dispose()
SPSite site = new SPSite("https://localhost");
SPWeb web = site.OpenWeb();

// Get a reference to the site content type collection.
SPContentTypeCollection contentTypes = web.ContentTypes;

// Create a Customer content type derived from the Item content type.
SPContentType contentType = new SPContentType(contentTypes["Item"], contentTypes, "Customer");

// Add the content type to the site collection.
contentType = contentTypes.Add(contentType);

// Clean up.
web.Dispose();
site.Dispose();

Siehe auch

Referenz

SPContentType Klasse

SPContentType-Member

SPContentType-Überladung

Microsoft.SharePoint-Namespace

Weitere Ressourcen

Introduction to Content Types

Site and List Content Types

Base Content Type Hierarchy