Skip to content

Instantly share code, notes, and snippets.

@tekguy
Last active January 2, 2016 17:49
Show Gist options
  • Save tekguy/8339013 to your computer and use it in GitHub Desktop.
Save tekguy/8339013 to your computer and use it in GitHub Desktop.
Visiblity Provider for MVCSiteMapProvider 4.0
namespace MyCompany.Web
{
public class MyCompanySiteMapVisibilityProvider : MvcSiteMapProvider.SiteMapNodeVisibilityProviderBase
{
public override bool IsVisible(ISiteMapNode node, IDictionary<string, object> sourceMetadata)
{
if (node == null)
{
return true;
}
// Is a visibility attribute specified?
var visibilityValue = node.Attributes.GetValue("visibility");
if (visibilityValue != null)
{
bool nodeVisible;
string visibility = visibilityValue.ToString();
if (bool.TryParse(visibility, out nodeVisible))
{
return nodeVisible;
}
}
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment