다음을 통해 공유


SPElementDefinition Class

Serves as the base class for implementing element types within 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)
Available in Sandboxed Solutions: No

Syntax

'Declaration
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPElementDefinition
'Usage
Dim instance As SPElementDefinition
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPElementDefinition

Remarks

Custom element types must derive from the SPElementDefinition class.

Use the GetElementDefinitions method of the SPFeatureDefinition class to return the collection of element definitions that are used in a Feature definition.

Examples

The following example iterates through all the Features in a site collection and uses the GetElementDefinitions method to return all the element definitions of the Features.

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.

See Also

Reference

SPElementDefinition Members

Microsoft.SharePoint.Administration Namespace