private void AddRecursive(IList<NavigationNode> navigationNodes, NavigationNode toAdd)
 {
     if (navigationNodes.Contains(toAdd))
     {
         foreach (var node in toAdd.Children)
         {
             AddRecursive(navigationNodes.Single(x => x.Name == toAdd.Name).Children, node);
         }
     }
     else
         navigationNodes.Add(toAdd);
 }
        public static string AddNavigationNode(HtmlHelper htmlHelper, NavigationNode node)
        {
            StringBuilder nodeOutput = new StringBuilder();

            if (node.Children.Count == 0)
            {
                nodeOutput.Append("<li>");
            }
            else
            {
                nodeOutput.Append("<li class=\"dropdown\">");
            }

            if (node.Children.Count == 0)
            {
                nodeOutput.Append(htmlHelper.ActionLink(node.Name, node.Action, node.Controller).ToString());
            }
            else
            {
                nodeOutput.Append(string.Format(@"<a href=""#"" class=""dropdown-toggle"" data-toggle=""dropdown"">{0}<b class=""caret""></b></a>", node.Name));
                nodeOutput.Append(AddSubMenu(htmlHelper, node.Children));
            }

            nodeOutput.Append("</li>");

            return nodeOutput.ToString();
        }
        public virtual bool Equals(NavigationNode other)
        {
            if (Name == other.Name)
                return true;

            return false;
        }
 private void AddInternal(NavigationNode path)
 {
     AddRecursive(NavigationNodes, path);
 }
        public static string AddMobileNavigationNode(HtmlHelper htmlHelper, NavigationNode node, string dataTheme, string dataContentTheme)
        {
            StringBuilder nodeOutput = new StringBuilder();

            if (node.Children.Count > 0)
            {
                nodeOutput.Append(string.Format("<div data-role=\"collapsible\" data-theme=\"{0}\" data-content-theme=\"{1}\">", dataTheme, dataContentTheme));
            }

            if (node.Children.Count == 0)
            {
                nodeOutput.Append(htmlHelper.ActionLink(node.Name, node.Action, node.Controller, null, new { data_role="button", rel="external" }).ToString());
            }
            else
            {
                nodeOutput.Append(AddMobileSubMenu(htmlHelper, node.Children));
            }

            if (node.Children.Count > 0)
            {
                nodeOutput.Append("</div>");
            }

            return nodeOutput.ToString();
        }