本文整理汇总了C#中System.Web.SiteMapNode.GetAllNodes方法的典型用法代码示例。如果您正苦于以下问题:C# SiteMapNode.GetAllNodes方法的具体用法?C# SiteMapNode.GetAllNodes怎么用?C# SiteMapNode.GetAllNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.SiteMapNode
的用法示例。
在下文中一共展示了SiteMapNode.GetAllNodes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindNodeAllowedForParentPage
//http://msdn.microsoft.com/en-us/library/system.web.sitemapnodecollection.aspx
//http://stackoverflow.com/questions/1960364/asp-net-enumerate-through-sitemapnode-childnodes
//foreach (var childNode in node.ChildNodes.OrderBy(x => x.Key))
//public static IEnumerable<SiteMapNode> OrderBy(this SiteMapNodeCollection smnc, Func<SiteMapNode, TKey> expression)
//{
// return smnc.Cast<SiteMapNode>().OrderBy(expression);
//}
//http://stackoverflow.com/questions/703130/linq-query-loses-order
public static SiteMapNode FindNodeAllowedForParentPage(SiteMapNode rootNode, string pageName)
{
//SiteMapNode node = rootNode.GetAllNodes().Cast().FirstOrDefault(n => n.Key.Equals(pagekey));
//return node != null ? node.Url : String.Empty;
SiteMapNode foundNode = (
from SiteMapNode cr in rootNode.GetAllNodes()
where cr.Title.StartsWith(pageName)
orderby cr.Title
select cr
).First();
mojoSiteMapNode mojoNode = foundNode as mojoSiteMapNode;
if (mojoNode != null)
{
if ((WebUser.IsInRoles(mojoNode.CreateChildPageRoles))||(WebUser.IsInRoles(mojoNode.CreateChildDraftPageRoles))) { return foundNode; }
}
return null;
}
示例2: IsSelectedNodeDescendantOf
/// <summary>
/// Check if the currently selected node is a decendant of the given node
/// </summary>
/// <param name="node">The node which may or may not be an ancestor of the currently selected node</param>
/// <param name="currentNode">The currently active SiteMapNode</param>
/// <returns>True if the currently selected node is a decendant of the given node</returns>
private static bool IsSelectedNodeDescendantOf(SiteMapNode node, SiteMapNode currentNode)
{
return node.GetAllNodes().Contains(currentNode);
}
示例3: GetSiteMapNodeForPage
public static mojoSiteMapNode GetSiteMapNodeForPage(SiteMapNode rootNode, int pageId)
{
if (rootNode == null) { return null; }
if (!(rootNode is mojoSiteMapNode)) { return null; }
foreach (SiteMapNode childNode in rootNode.GetAllNodes())
{
if (!(childNode is mojoSiteMapNode)) { return null; }
mojoSiteMapNode node = childNode as mojoSiteMapNode;
if (node.PageId == pageId) { return node; }
}
return null;
}
示例4: ChangeCultureSiteMap
private SiteMapNode ChangeCultureSiteMap(SiteMapNode rootToChange, string uiCulture)
{
if (!rootToChange.HasChildNodes)
return rootToChange;
foreach (SiteMapNode node in rootToChange.GetAllNodes())
{
if (Thread.CurrentThread.CurrentUICulture.Name.Contains("es"))
{
if (_nodesEsp.ContainsKey(int.Parse(node.Key)))
{
node.Title = _nodesEsp[int.Parse(node.Key)];
node.Description = _nodesEsp[int.Parse(node.Key)];
}
}
else if (Thread.CurrentThread.CurrentUICulture.Name.Contains("en"))
{
if (_nodes.ContainsKey(int.Parse(node.Key)))
{
node.Title = _nodesEn[int.Parse(node.Key)];
node.Description = _nodesEn[int.Parse(node.Key)];
}
}
}
return rootToChange;
}