ContentType 類別
表示SPContentType物件。
繼承階層架構
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
範例
此程式碼範例初始化自訂內容類型,將它加入各種內容類型,並顯示指定的網站的內容類型的名稱。
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);
}
}
}
執行緒安全
這類型的任何公用 static (共用 於 Visual Basic 中) 成員是安全執行緒。不保證任何執行個體成員都是安全執行緒。