ContentType 类
Represents a SPContentType object.
继承层次结构
System.Object
Microsoft.SharePoint.Client.ClientObject
Microsoft.SharePoint.Client.ContentType
命名空间: Microsoft.SharePoint.Client
程序集: Microsoft.SharePoint.Client.Silverlight(位于 Microsoft.SharePoint.Client.Silverlight.dll 中); Microsoft.SharePoint.Client.Phone(位于 Microsoft.SharePoint.Client.Phone.dll 中) Microsoft.SharePoint.Client(位于 Microsoft.SharePoint.Client.dll 中)
语法
声明
Public NotInheritable Class ContentType _
Inherits ClientObject
用法
Dim instance As ContentType
public sealed class ContentType : ClientObject
示例
This code example initializes a custom content type, adds it to the collection of content types, and displays the names of the specified website’s content types.
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);
}
}
}
线程安全性
该类型的任何公共 静态 (已共享 在 Visual Basic 中) 成员都是线程安全的。不保证任何实例成员都是线程安全的。