Which code segment should you use?

You have a SharePoint farm that has more than 100 custom Features. You upgrade several
Features in the farm. You need to ensure that the site collection uses the most up-to-date
versions of the Features. Only Features that require an upgrade must be evaluated. Which code
segment should you use?

You have a SharePoint farm that has more than 100 custom Features. You upgrade several
Features in the farm. You need to ensure that the site collection uses the most up-to-date
versions of the Features. Only Features that require an upgrade must be evaluated. Which code
segment should you use?

A.
Dim web As SPWeb = SPContext.Current.Web Dim allFeatures As SPFeatureCollection =
web.Features For Each currentFeature As SPFeature In allFeatures
currentFeature.Upgrade(True) Next

B.
Dim site As SPSite = SPContext.Current.Site Dim allFeatures As SPFeatureCollection =
site.Features For Each currentFeature As SPFeature In allFeatures
currentFeature.Upgrade(True) Next

C.
Dim webServices As New SPWebServiceCollection(SPFarm.Local) For Each myWebService1
As SPWebService In webServices Dim queryResults As SPFeatureQueryResultCollection =
myWebService1.QueryFeatures(SPFeatureScope.Site, True) Dim featureEnumerator As
IEnumerator(Of SPFeature) = queryResults.GetEnumerator() While
featureEnumerator.MoveNext() Dim feature As SPFeature = featureEnumerator.Current
feature.Upgrade(False) End While Next

D.
Dim webServices As New SPWebServiceCollection(SPFarm.Local) For Each myWebService1
As SPWebService In webServices Dim queryResults As SPFeatureQueryResultCollection =
myWebService1.QueryFeatures(SPFeatureScope.Web, True) Dim featureEnumerator As
IEnumerator(Of SPFeature) = queryResults.GetEnumerator() While
featureEnumerator.MoveNext() Dim feature As SPFeature = featureEnumerator.Current
feature.Upgrade(False) End While Next



Leave a Reply 0

Your email address will not be published. Required fields are marked *