共用方式為


SPFeatureDefinition class

會包含一種功能,包括其名稱、 識別碼、 範圍與版本的基底定義。

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.SPPersistedObject
      Microsoft.SharePoint.Administration.SPFeatureDefinition

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
<GuidAttribute("6F6F021A-1055-4718-AB6E-FE85743C5FD9")> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class SPFeatureDefinition _
    Inherits SPPersistedObject
'用途
Dim instance As SPFeatureDefinition
[GuidAttribute("6F6F021A-1055-4718-AB6E-FE85743C5FD9")]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class SPFeatureDefinition : SPPersistedObject

備註

使用SPFarm類別之FeatureDefinitions屬性來取得安裝在伺服器陣列中的功能定義集合。若要新增至集合中的功能定義,使用其中一個SPFeatureDefinitionCollection類別的Add方法。集合中加入一種功能會安裝此功能在伺服器陣列,使其成為可用於啟用其指定範圍中。新增具有伺服器陣列範圍的功能會安裝功能,不僅啟動伺服器陣列中。

若要從集合中傳回單一的功能定義使用索引器。例如,若集合已指派給變數myDefinitions,使用以 C# myDefinitions[index]或Visual Basic,在myDefinitions(index)index所在之功能的 GUID。

注意

若要建立功能定義物件,您無法使用SPFeatureDefinition建構函式。這不受支援,並傳回NullReferenceException ,如果您嘗試實作透過建構函式建立的物件的成員。

Examples

下面範例會在伺服器陣列安裝的功能定義。此範例假設自訂的資料夾已新增至包含指定的 GUID,該功能的 Feature.xml 檔案的 「 功能 」 目錄。這個範例需要在using指示詞 (ImportsVisual Basic的Microsoft.SharePointMicrosoft.SharePoint.Administration命名空間中。

[C#]

System.Globalization.CultureInfo cInfo = new System.Globalization.CultureInfo(1033);

SPFeatureDefinitionCollection farmFeatures = SPFarm.Local.FeatureDefinitions;

Guid farmGuid = new Guid("BCFC1029-7DB4-4e9c-B162-B03CE8497DAC");

SPFeatureDefinition featureDefinition = farmFeatures.Add(@"Feature_Folder\Feature.xml", farmGuid, true);

Response.Write("Farm definition " + SPEncode.HtmlEncode(featureDefinition.GetTitle(cInfo)) + " added.<BR>");

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.

請參閱

參照

SPFeatureDefinition members

Microsoft.SharePoint.Administration namespace