本文整理汇总了C#中ISiteMapNode.IsVisible方法的典型用法代码示例。如果您正苦于以下问题:C# ISiteMapNode.IsVisible方法的具体用法?C# ISiteMapNode.IsVisible怎么用?C# ISiteMapNode.IsVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISiteMapNode
的用法示例。
在下文中一共展示了ISiteMapNode.IsVisible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldNodeRender
/// <summary>
/// Checks all rules to determine if the current node should render in the sitemap.
/// </summary>
/// <param name="node">The node</param>
/// <param name="context">The controller context</param>
/// <returns><b>true</b> if the current node should be rendered; otherwise<b>false</b>.</returns>
protected virtual bool ShouldNodeRender(ISiteMapNode node, ControllerContext context)
{
return node.Clickable &&
node.IsVisible(SourceMetadata) &&
!node.HasExternalUrl(context.HttpContext) &&
string.IsNullOrEmpty(node.CanonicalUrl) &&
!node.HasNoIndexAndNoFollow &&
!this.IsDuplicateUrl(node);
}
示例2: FlattenHierarchy
/// <summary>
/// Generates flat list of SiteMapNode from SiteMap hierarchy.
/// </summary>
/// <param name="startingNode">The starting node.</param>
/// <param name="context">The controller context.</param>
/// <param name="visibilityAffectsDescendants">A boolean indicating whether visibility of the current node should affect the visibility of descendant nodes.</param>
/// <returns>A flat list of SiteMapNode.</returns>
protected virtual IEnumerable<ISiteMapNode> FlattenHierarchy(ISiteMapNode startingNode, ControllerContext context, bool visibilityAffectsDescendants)
{
// Inaccessible - don't process current node or any descendant nodes.
if (startingNode.IsAccessibleToUser() && (visibilityAffectsDescendants ? startingNode.IsVisible(SourceMetadata) : true))
{
if (this.ShouldNodeRender(startingNode, context))
{
yield return startingNode;
}
if (startingNode.HasChildNodes)
{
// Make sure all child nodes are accessible prior to rendering them...
foreach (ISiteMapNode node in startingNode.ChildNodes)
{
foreach (var childNode in FlattenHierarchy(node, context, visibilityAffectsDescendants))
{
yield return childNode;
}
}
}
}
}