Skip to content

Commit

Permalink
Fixes #375, TrimEmptyGroupingNodesVisibilityProvider doesn't work wit…
Browse files Browse the repository at this point in the history
…h nested visibility providers.
  • Loading branch information
NightOwl888 committed Jan 30, 2015
1 parent b868191 commit b0e3105
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace MvcSiteMapProvider
{
/// <summary>
/// Removes non-clickable nodes that have no accessible children.
/// Removes non-clickable nodes that have no accessible and/or visible children.
/// </summary>
public class TrimEmptyGroupingNodesVisibilityProvider
: SiteMapNodeVisibilityProviderBase
{
public override bool IsVisible(ISiteMapNode node, IDictionary<string, object> sourceMetadata)
{
if (!node.HasChildNodes && !node.Clickable)
// Optimization - return quickly if clickable.
if (node.Clickable)
{
return false;
return true;
}
return true;

var childNodes = node.ChildNodes;
return childNodes == null || childNodes.Any(c => c.IsVisible(sourceMetadata));
}
}
}

0 comments on commit b0e3105

Please sign in to comment.