private static BreadcrumbNode GetTypeRootNode(Type rootType, BreadcrumbAttribute rootAttribute)
        {
            var rootNode = new BreadcrumbNode()
            {
                Type       = rootType,
                ParentType = rootAttribute.Parent,
                Name       = rootAttribute.Name ?? rootType.Name.Replace("Controller", string.Empty)
            };

            rootNode.Children = rootType.GetMethods()
                                .Select(x => (x, x.GetCustomAttribute <BreadcrumbAttribute>()))
                                .Where(x => x.Item2 != null)
                                .Select(x => new BreadcrumbNode()
            {
                Parent = rootNode, Name = x.Item2.Name ?? x.Item1.Name
            })
                                .ToList();

            if (rootNode.Children.Count == 0)
            {
                rootNode.Children.Add(new BreadcrumbNode()
                {
                    Parent = rootNode, Name = "Index"
                });
            }

            return(rootNode);
        }
        public static List <BreadcrumbNode> GetPath(BreadcrumbNode tree, string controller, string action)
        {
            var targetNode = FindNode(tree, controller, action);
            var path       = new List <BreadcrumbNode>();

            while (targetNode != null)
            {
                path.Add(targetNode);
                targetNode = targetNode.Parent;
            }
            return(path);
        }
 private static BreadcrumbNode FindNode(BreadcrumbNode node, string controller, string action)
 {
     if (node.Name.Equals(action, StringComparison.OrdinalIgnoreCase) &&
         node.Parent != null &&
         node.Parent.Name.Equals(controller, StringComparison.OrdinalIgnoreCase))
     {
         return(node);
     }
     if (node.Children != null)
     {
         foreach (var child in node.Children)
         {
             var targetNode = FindNode(child, controller, action);
             if (targetNode != null)
             {
                 return(targetNode);
             }
         }
     }
     return(null);
 }