本文整理汇总了C#中ISiteMapNode.IsAccessibleToUser方法的典型用法代码示例。如果您正苦于以下问题:C# ISiteMapNode.IsAccessibleToUser方法的具体用法?C# ISiteMapNode.IsAccessibleToUser怎么用?C# ISiteMapNode.IsAccessibleToUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISiteMapNode
的用法示例。
在下文中一共展示了ISiteMapNode.IsAccessibleToUser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsAccessibleToUser
/// <summary>
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
public bool IsAccessibleToUser(ISiteMapNode node)
{
string operatorExpress = node.Attributes.ContainsKey("permission")
? (string) node.Attributes["permission"]
: null;
if (String.IsNullOrEmpty(operatorExpress))
{
return node.IsAccessibleToUser();
}
var permission = new MenuPermission(operatorExpress, _memberShipContext);
return permission.HasRight(OrnamentContext.MemberShip.CurrentUser());
}
示例2: ReturnNodeIfAccessible
protected virtual ISiteMapNode ReturnNodeIfAccessible(ISiteMapNode node)
{
if ((node != null) && node.IsAccessibleToUser())
{
return node;
}
return null;
}
示例3: 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;
}
}
}
}
}