Last active
January 2, 2016 17:49
-
-
Save tekguy/8339013 to your computer and use it in GitHub Desktop.
Visiblity Provider for MVCSiteMapProvider 4.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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