/// <summary>
 /// Test if the maximal nodelevel has not been reached
 /// </summary>
 /// <param name="maxDepth">The normal max depth.</param>
 /// <param name="node">The starting node</param>
 /// <param name="drillDownToCurrent">Should the model exceed the maxDepth to reach the current node</param>
 /// <returns></returns>
 private static bool ReachedMaximalNodelevel(int maxDepth, SiteMapNode node, bool drillDownToCurrent)
 {
     if (maxDepth > 0)
     {
         return(true);
     }
     if (!drillDownToCurrent)
     {
         return(false);
     }
     if (node.IsInCurrentPath())
     {
         return(true);
     }
     if (node.ParentNode == node.Provider.CurrentNode)
     {
         return(true);
     }
     foreach (SiteMapNode sibling in node.ParentNode.ChildNodes)
     {
         if (sibling.IsInCurrentPath())
         {
             return(true);
         }
     }
     return(false);
 }
        /// <summary>
        /// Maps to SiteMapNodeModel.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="mvcNode">The MVC node.</param>
        /// <param name="sourceMetadata">The source metadata provided by the HtmlHelper.</param>
        /// <returns>SiteMapNodeModel instance.</returns>
        public static SiteMapNodeModel MapToSiteMapNodeModel(SiteMapNode node, MvcSiteMapNode mvcNode, IDictionary <string, object> sourceMetadata)
        {
            var nodeToAdd = new SiteMapNodeModel
            {
                Area            = (mvcNode != null ? mvcNode.Area : ""),
                Controller      = (mvcNode != null ? mvcNode.Controller : ""),
                Action          = (mvcNode != null ? mvcNode.Action : ""),
                Title           = node.Title,
                Description     = node.Description,
                TargetFrame     = (mvcNode == null ? "" : mvcNode.TargetFrame),
                Url             = node.Url,
                IsCurrentNode   = node == node.Provider.CurrentNode,
                IsInCurrentPath = node.IsInCurrentPath(),
                IsRootNode      = node == node.Provider.RootNode,
                IsClickable     = (mvcNode == null || mvcNode.Clickable),
                RouteValues     = (mvcNode != null ? mvcNode.RouteValues : new Dictionary <string, object>()),
                MetaAttributes  = (mvcNode != null ? mvcNode.MetaAttributes : new Dictionary <string, string>()),
                SourceMetadata  = sourceMetadata
            };

            return(nodeToAdd);
        }
 /// <summary>
 /// Test if the maximal nodelevel has not been reached
 /// </summary>
 /// <param name="maxDepth">The normal max depth.</param>
 /// <param name="node">The starting node</param>
 /// <param name="drillDownToCurrent">Should the model exceed the maxDepth to reach the current node</param>
 /// <returns></returns>
 private static bool ReachedMaximalNodelevel(int maxDepth, SiteMapNode node, bool drillDownToCurrent)
 {
     if (maxDepth > 0)
         return true;
     if (!drillDownToCurrent)
         return false;
     if (node.IsInCurrentPath())
         return true;
     if (node.ParentNode == node.Provider.CurrentNode)
         return true;
     foreach (SiteMapNode sibling in node.ParentNode.ChildNodes)
     {
         if (sibling.IsInCurrentPath())
             return true;
     }
     return false;
 }