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.
SPWebServiceCollection webServices = new SPWebServiceCollection(SPFarm.Local);
foreach (SPWebService myWebService1 in webServices) { SPFeatureQueryResultCollection
queryResults = myWebService1.QueryFeatures (SPFeatureScope.Site, true);
IEnumerator<SPFeature> featureEnumerator = queryResults.GetEnumerator(); while
(featureEnumerator.MoveNext()) { SPFeature feature = featureEnumerator.Current;
feature.Upgrade(false); } }

B.
SPWebServiceCollection webServices = new SPWebServiceCollection(SPFarm.Local);
foreach (SPWebService myWebService1 in webServices) { SPFeatureQueryResultCollection
queryResults = myWebService1.QueryFeatures (SPFeatureScope.Web, true);
IEnumerator<SPFeature> featureEnumerator = queryResults.GetEnumerator(); while
(featureEnumerator.MoveNext()) { SPFeature feature = featureEnumerator.Current;
feature.Upgrade(false); } }

C.
SPSite site = SPContext.Current.Site; SPFeatureCollection allFeatures = site.Features;
foreach (SPFeature currentFeature in allFeatures) { currentFeature.Upgrade(true); }

D.
SPWeb web = SPContext.Current.Web; SPFeatureCollection allFeatures = web.Features;
foreach (SPFeature currentFeature in allFeatures) { currentFeature.Upgrade(true); }



Leave a Reply 0

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