本文整理汇总了C#中ISiteMap.GetChildNodes方法的典型用法代码示例。如果您正苦于以下问题:C# ISiteMap.GetChildNodes方法的具体用法?C# ISiteMap.GetChildNodes怎么用?C# ISiteMap.GetChildNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISiteMap
的用法示例。
在下文中一共展示了ISiteMap.GetChildNodes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNodesFromMvcSiteMapNodeAttributeDefinitions
//.........这里部分代码省略.........
foreach (var assemblyNode in definitions.Where(t => !string.IsNullOrEmpty(t.SiteMapNodeAttribute.ParentKey)))
{
ISiteMapNode nodeToAdd = null;
// Create node
var actionNode = assemblyNode as MvcSiteMapNodeAttributeDefinitionForAction;
if (actionNode != null)
{
// Create node for action
nodeToAdd = GetSiteMapNodeFromMvcSiteMapNodeAttribute(
siteMap, actionNode.SiteMapNodeAttribute, actionNode.ControllerType, actionNode.ActionMethodInfo);
}
else
{
var controllerNode = assemblyNode as MvcSiteMapNodeAttributeDefinitionForController;
if (controllerNode != null)
{
// Create node for controller
nodeToAdd = GetSiteMapNodeFromMvcSiteMapNodeAttribute(
siteMap, controllerNode.SiteMapNodeAttribute, controllerNode.ControllerType, null);
}
}
// Add node
if (nodeToAdd != null)
{
if (string.IsNullOrEmpty(assemblyNode.SiteMapNodeAttribute.ParentKey))
{
throw new MvcSiteMapException(string.Format(Resources.Messages.NoParentKeyDefined, nodeToAdd.Controller, nodeToAdd.Action));
}
var parentForNode = parentNode != null ? siteMap.FindSiteMapNodeFromKey(assemblyNode.SiteMapNodeAttribute.ParentKey) : null;
if (parentForNode != null)
{
if (nodeToAdd.HasDynamicNodeProvider)
{
var dynamicNodesForChildNode = dynamicNodeBuilder.BuildDynamicNodesFor(siteMap, nodeToAdd, parentForNode);
foreach (var dynamicNode in dynamicNodesForChildNode)
{
// Verify parent/child relation
if (dynamicNode.ParentNode.Equals(parentNode)
&& !siteMap.GetChildNodes(parentNode).Contains(dynamicNode))
{
siteMap.AddNode(dynamicNode, parentNode);
}
}
}
else
{
siteMap.AddNode(nodeToAdd, parentForNode);
}
}
else
{
nodesToProcessLater.Add(nodeToAdd, assemblyNode.SiteMapNodeAttribute.ParentKey);
}
}
}
// Process list of nodes that did not have a parent defined.
// If this does not succeed at this time, parent will default to root node.
if (parentNode != null)
{
foreach (var nodeToAdd in nodesToProcessLater)
{
var parentForNode = siteMap.FindSiteMapNodeFromKey(nodeToAdd.Value);
if (parentForNode == null)
{
var temp = nodesToProcessLater.Keys.Where(t => t.Key == nodeToAdd.Value).FirstOrDefault();
if (temp != null)
{
parentNode = temp;
}
}
if (parentForNode != null)
{
if (nodeToAdd.Key.HasDynamicNodeProvider)
{
var dynamicNodesForChildNode = dynamicNodeBuilder.BuildDynamicNodesFor(siteMap, nodeToAdd.Key, parentForNode);
foreach (var dynamicNode in dynamicNodesForChildNode)
{
// Verify parent/child relation
if (dynamicNode.ParentNode.Equals(parentNode)
&& !siteMap.GetChildNodes(parentNode).Contains(dynamicNode))
{
siteMap.AddNode(dynamicNode, parentNode);
}
}
}
else
{
siteMap.AddNode(nodeToAdd.Key, parentForNode);
}
}
}
}
return parentNode;
}