Windows SharePoint Services 3.0 provides a complete set of object models for listing the feature installed within a given range and controlling whether the feature is available on the server farm or at the website level.
Feature class library
-
Microsoft. Sharepoint. spfeature(SpfeaturecollectionReturns an object that describes the status of feature in the corresponding layer. Existence in the feature set in the Presence (Microsoft. Sharepoint. Administration. spwebservice), Web ApplicationsProgramOf (Microsoft. Sharepoint. Administration. spwebapplication), Website set (Microsoft. Sharepoint. spsite), Or the website's (Microsoft. Sharepoint. spweb) Indicates whether the feature is activated. If the corresponding ISpfeatureThe feature is not activated within the specified range. Namespace: Microsoft. SharePoint
Microsoft. Sharepoint. spfeatureproperty(Spfeaturepropertycollection) Represents the attributes of a feature. Namespace:Microsoft. SharePoint
-
Microsoft. Sharepoint. spfeaturescopeAn enumeration of possible ranges that can be specified, includingFarm,Webapplication,Site, AndWeb. Namespace:Microsoft. SharePoint
-
Microsoft. Sharepoint. Administration. spfeaturedefinition(SpfeaturedefinitioncollectionIncludes the basic definition of a feature, including the name, range, ID, and version. At the same time, some global attributes in each featue can be stored. Namespace: Microsoft. Sharepoint. Administration
Microsoft. Sharepoint. spfeaturedependency(Spfeaturedependencycollection) Represents the dependency with a feature. Namespace:Microsoft. SharePoint
-
Microsoft. Sharepoint. Administration. spelementdefinition(Spelementdefinitioncollection) Represents some elements preset when the feature is activated or used. Namespace:Microsoft. Sharepoint. Administration
Access the feature set
To obtain a set of WSS Web applications (virtual servers), website sets, and inner feature, you can use one of the following attributes to access the set:
Microsoft. Sharepoint. Administration. spwebapplication. FeaturesReturns a list of activated feature values within the scope of a virtual server, that is, within the scope of a Web application.
Microsoft. Sharepoint. Administration. spwebservice. FeaturesReturns the management feature of the server farm range.
Microsoft. Sharepoint. Administration. spfarm. featuredefinitionsReturn the list of all feature packages installed on the server.
Microsoft. Sharepoint. spsite. FeaturesReturn to the feature list of the activation status in the website set.
Microsoft. Sharepoint. spweb. FeaturesReturn to the feature list of the activation status on the website.
Microsoft. Sharepoint. Administration. spfeaturedefinition. activationdependenciesReturns the list of feature dependent on which a feature is activated.
Example
The following example lists the names and guids of all feature activated on a specific website:
Spsite sitecollection = Spcontrol. getcontextsite (context );
Spweb site = Sitecollection. allwebs [ " Site " ];
Spfeaturecollection sitefeatures = Site. features;
System. Globalization. cultureinfo = New System. Globalization. cultureinfo ( 1033 );
Foreach (Spfeature sitefeature In Sitefeatures)
{
Response. Write ( " Title: " + Sitefeature. Definition. gettitle (cultureinfo) + " <Br> ID: "
+ Sitefeature. definitionid. tostring () + " <Br> " );
}
The following example uses the information returned above to add the feature to the sub-Website:
Spweb subsite = Site. webs [ " Subsite " ];
System. guid = New System. GUID ( " 6e005f62-f8b2-4073-a673-c035c9129946 " );
Subsite. features. Add (guid );