Freigeben über


ContentType-Klasse

Ein SPContentType Objekt darstellt.

Vererbungshierarchie

System.Object
  Microsoft.SharePoint.Client.ClientObject
    Microsoft.SharePoint.Client.ContentType

Namespace:  Microsoft.SharePoint.Client
Assemblys:   Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll);  Microsoft.SharePoint.Client.Phone (in Microsoft.SharePoint.Client.Phone.dll)  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)

Syntax

'Declaration
Public NotInheritable Class ContentType _
    Inherits ClientObject
'Usage
Dim instance As ContentType
public sealed class ContentType : ClientObject

Beispiele

In diesem Codebeispiel einer benutzerdefinierten Inhalt Typ, die Sammlung von Inhaltstypen hinzugefügt und zeigt die Namen von Inhaltstypen für die angegebene Website.

using System;
using Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointFoundation.Samples
{
    class ContentTypeExample
    {
        static void Main()
        {

            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            Web site = clientContext.Web;
            ContentTypeCollection collContentType = site.ContentTypes;

            // Initialize a new content type.
            ContentTypeCreationInformation contentInfo = new ContentTypeCreationInformation();
            contentInfo.Name = "myContentType";
            contentInfo.Description = "My custom content type";
            ContentType contentType = collContentType.Add(contentInfo);

            clientContext.Load(collContentType);
            clientContext.ExecuteQuery();

            foreach (ContentType myType in collContentType)
                Console.WriteLine("Content Type Name: {0}", myType.Name);
        }

    }
}

Threadsicherheit

Alle öffentlichen static (Shared in Visual Basic) Member dieses Typs sind threadsicher. Die Threadsicherheit von Instanzmembern ist nicht gewährleistet.

Siehe auch

Referenz

ContentType-Member

Microsoft.SharePoint.Client-Namespace