本文整理汇总了C#中Web.IsPublishingWeb方法的典型用法代码示例。如果您正苦于以下问题:C# Web.IsPublishingWeb方法的具体用法?C# Web.IsPublishingWeb怎么用?C# Web.IsPublishingWeb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Web
的用法示例。
在下文中一共展示了Web.IsPublishingWeb方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProvisionObjects
public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
{
using (var scope = new PnPMonitoredScope(this.Name))
{
if (template.Navigation != null)
{
// The Navigation handler works only for sites with Publishing Features enabled
if (!web.IsPublishingWeb())
{
scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_Navigation_Context_web_is_not_publishing);
return parser;
}
// Retrieve the current web navigation settings
var navigationSettings = new WebNavigationSettings(web.Context, web);
web.Context.Load(navigationSettings, ns => ns.CurrentNavigation, ns => ns.GlobalNavigation);
web.Context.ExecuteQueryRetry();
if (template.Navigation.GlobalNavigation != null)
{
switch (template.Navigation.GlobalNavigation.NavigationType)
{
case GlobalNavigationType.Inherit:
navigationSettings.GlobalNavigation.Source = StandardNavigationSource.InheritFromParentWeb;
break;
case GlobalNavigationType.Managed:
if (template.Navigation.GlobalNavigation.ManagedNavigation == null)
{
throw new ApplicationException(CoreResources.Provisioning_ObjectHandlers_Navigation_missing_global_managed_navigation);
}
navigationSettings.GlobalNavigation.Source = StandardNavigationSource.TaxonomyProvider;
navigationSettings.GlobalNavigation.TermStoreId = Guid.Parse(parser.ParseString(template.Navigation.GlobalNavigation.ManagedNavigation.TermStoreId));
navigationSettings.GlobalNavigation.TermSetId = Guid.Parse(parser.ParseString(template.Navigation.GlobalNavigation.ManagedNavigation.TermSetId));
break;
case GlobalNavigationType.Structural:
default:
if (template.Navigation.GlobalNavigation.StructuralNavigation == null)
{
throw new ApplicationException(CoreResources.Provisioning_ObjectHandlers_Navigation_missing_global_structural_navigation);
}
ProvisionGlobalStructuralNavigation(web,
template.Navigation.GlobalNavigation.StructuralNavigation, parser);
break;
}
web.Context.ExecuteQueryRetry();
}
if (template.Navigation.CurrentNavigation != null)
{
switch (template.Navigation.CurrentNavigation.NavigationType)
{
case CurrentNavigationType.Inherit:
navigationSettings.CurrentNavigation.Source = StandardNavigationSource.InheritFromParentWeb;
break;
case CurrentNavigationType.Managed:
if (template.Navigation.CurrentNavigation.ManagedNavigation == null)
{
throw new ApplicationException(CoreResources.Provisioning_ObjectHandlers_Navigation_missing_current_managed_navigation);
}
navigationSettings.CurrentNavigation.Source = StandardNavigationSource.TaxonomyProvider;
navigationSettings.CurrentNavigation.TermStoreId = Guid.Parse(parser.ParseString(template.Navigation.CurrentNavigation.ManagedNavigation.TermStoreId));
navigationSettings.CurrentNavigation.TermSetId = Guid.Parse(parser.ParseString(template.Navigation.CurrentNavigation.ManagedNavigation.TermSetId));
break;
case CurrentNavigationType.StructuralLocal:
web.SetPropertyBagValue(NavigationShowSiblings, "false");
if (template.Navigation.CurrentNavigation.StructuralNavigation == null)
{
throw new ApplicationException(CoreResources.Provisioning_ObjectHandlers_Navigation_missing_current_structural_navigation);
}
ProvisionCurrentStructuralNavigation(web,
template.Navigation.CurrentNavigation.StructuralNavigation, parser);
break;
case CurrentNavigationType.Structural:
default:
if (template.Navigation.CurrentNavigation.StructuralNavigation == null)
{
throw new ApplicationException(CoreResources.Provisioning_ObjectHandlers_Navigation_missing_current_structural_navigation);
}
ProvisionCurrentStructuralNavigation(web,
template.Navigation.CurrentNavigation.StructuralNavigation, parser);
break;
}
web.Context.ExecuteQueryRetry();
}
}
}
return parser;
}
示例2: WillExtract
public override bool WillExtract(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
{
return web.IsPublishingWeb();
}
示例3: WillProvision
public override bool WillProvision(Web web, ProvisioningTemplate template)
{
return web.IsPublishingWeb() && template.Navigation != null;
}
示例4: ExtractObjects
public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
{
using (var scope = new PnPMonitoredScope(this.Name))
{
GlobalNavigationType globalNavigationType;
CurrentNavigationType currentNavigationType;
// The Navigation handler works only for sites with Publishing Features enabled
if (!web.IsPublishingWeb())
{
scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_Navigation_Context_web_is_not_publishing);
return template;
}
// Retrieve the current web navigation settings
var navigationSettings = new WebNavigationSettings(web.Context, web);
web.Context.Load(navigationSettings, ns => ns.CurrentNavigation, ns => ns.GlobalNavigation);
web.Context.ExecuteQueryRetry();
switch (navigationSettings.GlobalNavigation.Source)
{
case StandardNavigationSource.InheritFromParentWeb:
// Global Navigation is Inherited
globalNavigationType = GlobalNavigationType.Inherit;
break;
case StandardNavigationSource.TaxonomyProvider:
// Global Navigation is Managed
globalNavigationType = GlobalNavigationType.Managed;
break;
case StandardNavigationSource.PortalProvider:
default:
// Global Navigation is Structural
globalNavigationType = GlobalNavigationType.Structural;
break;
}
switch (navigationSettings.CurrentNavigation.Source)
{
case StandardNavigationSource.InheritFromParentWeb:
// Current Navigation is Inherited
currentNavigationType = CurrentNavigationType.Inherit;
break;
case StandardNavigationSource.TaxonomyProvider:
// Current Navigation is Managed
currentNavigationType = CurrentNavigationType.Managed;
break;
case StandardNavigationSource.PortalProvider:
default:
// Current Navigation is Structural
if (AreSiblingsEnabledForCurrentStructuralNavigation(web))
{
currentNavigationType = CurrentNavigationType.Structural;
}
else
{
currentNavigationType = CurrentNavigationType.StructuralLocal;
}
break;
}
template.Navigation = new Model.Navigation(
new GlobalNavigation(globalNavigationType,
globalNavigationType == GlobalNavigationType.Structural ? GetGlobalStructuralNavigation(web, navigationSettings) : null,
globalNavigationType == GlobalNavigationType.Managed ? GetGlobalManagedNavigation(web, navigationSettings) : null),
new CurrentNavigation(currentNavigationType,
currentNavigationType == CurrentNavigationType.Structural | currentNavigationType == CurrentNavigationType.StructuralLocal ? GetCurrentStructuralNavigation(web, navigationSettings) : null,
currentNavigationType == CurrentNavigationType.Managed ? GetCurrentManagedNavigation(web, navigationSettings) : null)
);
}
return template;
}