本文整理汇总了C#中Web.IsFeatureActive方法的典型用法代码示例。如果您正苦于以下问题:C# Web.IsFeatureActive方法的具体用法?C# Web.IsFeatureActive怎么用?C# Web.IsFeatureActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Web
的用法示例。
在下文中一共展示了Web.IsFeatureActive方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeactivateMDS
private static void DeactivateMDS(Web currentWeb)
{
Guid minimalDownloadStrategyFeatureGuid = new Guid(spFeatureMinimalDownloadStrategy);
if (currentWeb.IsFeatureActive(minimalDownloadStrategyFeatureGuid))
{
Console.WriteLine("Deactivating web-scoped 'Minimal Download Strategy' feature for web at: " + currentWeb.Url);
currentWeb.DeactivateFeature(minimalDownloadStrategyFeatureGuid);
}
WebCollection webs = currentWeb.Webs;
clientContext.Load(webs);
clientContext.ExecuteQuery();
foreach(Web web in webs)
{
DeactivateMDS(web);
}
}
示例2: ExtractObjects
public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
{
using (var scope = new PnPMonitoredScope(this.Name))
{
if (web.IsFeatureActive(PUBLISHING_FEATURE_WEB))
{
web.EnsureProperty(w => w.Language);
var webTemplates = web.GetAvailableWebTemplates(web.Language, false);
web.Context.Load(webTemplates, wts => wts.Include(wt => wt.Name, wt => wt.Lcid));
web.Context.ExecuteQueryRetry();
Publishing publishing = new Publishing();
publishing.AvailableWebTemplates.AddRange(webTemplates.AsEnumerable<WebTemplate>().Select(wt => new AvailableWebTemplate() { TemplateName = wt.Name, LanguageCode = (int)wt.Lcid }));
publishing.AutoCheckRequirements = AutoCheckRequirementsOptions.MakeCompliant;
publishing.DesignPackage = null;
publishing.PageLayouts.AddRange(GetAvailablePageLayouts(web));
template.Publishing = publishing;
}
}
return template;
}
示例3: ProvisionObjects
public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
{
using (var scope = new PnPMonitoredScope(this.Name))
{
var site = (web.Context as ClientContext).Site;
var webFeatureActive = web.IsFeatureActive(PUBLISHING_FEATURE_WEB);
var siteFeatureActive = site.IsFeatureActive(PUBLISHING_FEATURE_SITE);
if (template.Publishing.AutoCheckRequirements == AutoCheckRequirementsOptions.SkipIfNotCompliant && !webFeatureActive)
{
scope.LogDebug("Publishing Feature (Web Scoped) not active. Skipping provisioning of Publishing settings");
return parser;
}
else if (template.Publishing.AutoCheckRequirements == AutoCheckRequirementsOptions.MakeCompliant)
{
if (!siteFeatureActive)
{
scope.LogDebug("Making site compliant for publishing");
site.ActivateFeature(PUBLISHING_FEATURE_SITE);
web.ActivateFeature(PUBLISHING_FEATURE_WEB);
}
else
{
if (!web.IsFeatureActive(PUBLISHING_FEATURE_WEB))
{
scope.LogDebug("Making site compliant for publishing");
web.ActivateFeature(PUBLISHING_FEATURE_WEB);
}
}
}
else
{
throw new Exception("Publishing Feature not active. Provisioning failed");
}
// Set allowed web templates
var availableWebTemplates = template.Publishing.AvailableWebTemplates.Select(t => new WebTemplateEntity() { LanguageCode = t.LanguageCode.ToString(), TemplateName = t.TemplateName }).ToList();
if (availableWebTemplates.Any())
{
web.SetAvailableWebTemplates(availableWebTemplates);
}
// Set allowed page layouts
var availablePageLayouts = template.Publishing.PageLayouts.Select(p => p.Path);
if (availablePageLayouts.Any())
{
web.SetAvailablePageLayouts(site.RootWeb, availablePageLayouts);
}
// Set default page layout, if any
var defaultPageLayout = template.Publishing.PageLayouts.FirstOrDefault(p => p.IsDefault);
if (defaultPageLayout != null)
{
web.SetDefaultPageLayoutForSite(site.RootWeb, defaultPageLayout.Path);
}
if (template.Publishing.DesignPackage != null)
{
var package = template.Publishing.DesignPackage;
var tempFileName = Path.Combine(Path.GetTempPath(), template.Connector.GetFilenamePart(package.DesignPackagePath));
scope.LogDebug("Saving {0} to temporary file: {1}", package.DesignPackagePath, tempFileName);
using (var stream = template.Connector.GetFileStream(package.DesignPackagePath))
{
using (var outstream = System.IO.File.Create(tempFileName))
{
stream.CopyTo(outstream);
}
}
scope.LogDebug("Installing design package");
site.InstallSolution(package.PackageGuid, tempFileName, package.MajorVersion, package.MinorVersion);
System.IO.File.Delete(tempFileName);
}
return parser;
}
}
示例4: WillExtract
public override bool WillExtract(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
{
return web.IsFeatureActive(PUBLISHING_FEATURE_WEB);
}
示例5: WillExtract
public override bool WillExtract(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
{
return web.IsFeatureActive(Constants.FeatureId_Web_Publishing);
}