SPElementDefinition class
做為基底類別的實作SharePoint Foundation內的項目類型。
Inheritance hierarchy
System.Object
Microsoft.SharePoint.Administration.SPElementDefinition
Microsoft.SharePoint.Administration.SPUserMigratorElement
Namespace: Microsoft.SharePoint.Administration
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPElementDefinition
'用途
Dim instance As SPElementDefinition
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPElementDefinition
備註
自訂項目類型都必須衍生自SPElementDefinition類別。
使用SPFeatureDefinition類別之GetElementDefinitions方法可傳回的可用的元素定義集合中的功能定義。
Examples
下列範例會逐一查看網站集合中的所有功能,並使用GetElementDefinitions方法來傳回所有的元素定義的功能。
Dim site As New SPSite("https://localhost")
Dim featureCollection As SPFeatureCollection = site.Features
Dim feature As SPFeature
For Each feature In featureCollection
Dim featureDefinition As SPFeatureDefinition = feature.Definition
Dim elementDefinitionCollection As SPElementDefinitionCollection = featureDefinition.GetElementDefinitions(System.Globalization.CultureInfo.InvariantCulture)
Dim elementDefinition As SPElementDefinition
For Each elementDefinition In elementDefinitionCollection
Console.WriteLine(elementDefinition.Id)
Next elementDefinition
Next feature
SPSite site = new SPSite("https://localhost");
SPFeatureCollection featureCollection = site.Features;
foreach (SPFeature feature in featureCollection)
{
SPFeatureDefinition featureDefinition = feature.Definition;
SPElementDefinitionCollection elementDefinitionCollection =
featureDefinition.GetElementDefinitions(System.Globalization.CultureInfo.InvariantCulture);
foreach (SPElementDefinition elementDefinition in elementDefinitionCollection)
{
Console.WriteLine(elementDefinition.Id);
}
}
Thread safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.