public override AgilitySiteMapNode Copy(string urlPath, AgilitySiteMapNode newParentNode)
        {
            AgilityDynamicSiteMapNode copyNode = (AgilityDynamicSiteMapNode)base.Copy(urlPath, newParentNode);

            copyNode.ReferenceName = ReferenceName;
            return(copyNode);
        }
        public virtual AgilitySiteMapNode Copy(string urlPath, AgilitySiteMapNode newParentNode)
        {
            string childPageName = this.PagePath;

            if (string.IsNullOrEmpty(childPageName))
            {
                childPageName = this.Url;
            }

            if (childPageName.EndsWith("/"))
            {
                childPageName = childPageName.Substring(0, childPageName.Length - 1);
            }
            int slashIndex = childPageName.LastIndexOf("/");

            if (slashIndex > 0)
            {
                childPageName = childPageName.Substring(slashIndex + 1);
            }
            string url = string.Format("{0}/{1}", urlPath, childPageName);

            string newPagePath = url;

            if (this.Url.StartsWith("javascript:", StringComparison.CurrentCultureIgnoreCase))
            {
                url = this.Url;
            }

            AgilitySiteMapNode node = null;

            if (node is AgilityDynamicSiteMapNode)
            {
                node = new AgilityDynamicSiteMapNode(this.Key, url, this.Title);
            }
            else
            {
                node = new AgilitySiteMapNode(this.Key, url, this.Title);
            }

            node.ParentNode   = newParentNode;
            node._agilityPage = this._agilityPage;

            node.PageItemID = this.PageItemID;
            node.PagePath   = newPagePath;

            node.ChildNodes = new List <AgilitySiteMapNode>();

            urlPath = newPagePath;
            if (urlPath.IndexOf(".aspx") > 0)
            {
                urlPath = urlPath.Substring(0, urlPath.IndexOf(".aspx"));
            }

            foreach (AgilitySiteMapNode childNode in ChildNodes)
            {
                node.ChildNodes.Add(childNode.Copy(urlPath, node));
            }

            return(node);
        }
        internal static AgilityDynamicSiteMapNode GetDynamicNode(AgilitySiteMapNode parentNode, Agility.Web.AgilityContentServer.DynamicPageFormulaItem pageFormulaItem, AgilityPage page)
        {
            string nodeID = string.Format("{0}_{1}", parentNode.Key, pageFormulaItem.ContentID);

            string menuText = pageFormulaItem.MenuText;
            string pageName = pageFormulaItem.Name;

            string url = parentNode.ParentNode.PagePath;

            if (string.IsNullOrEmpty(url))
            {
                url = parentNode.ParentNode.Url;
            }


            int index = url.LastIndexOf(".aspx", StringComparison.CurrentCultureIgnoreCase);

            if (index > 0)
            {
                url = url.Substring(0, index);
            }

            bool addAspx = true;

            if (AgilityContext.Domain != null && AgilityContext.Domain.ExtensionlessUrls)
            {
                addAspx = false;
            }

            string urlPath = string.Format("{0}/{1}", url, pageName);

            url = string.Format("{0}/{1}", url, pageName);
            if (addAspx)
            {
                url = string.Format("{0}.aspx", url);
            }
            if (url.StartsWith("/"))
            {
                url = string.Format("~{0}", url);
            }

            AgilityDynamicSiteMapNode node = new AgilityDynamicSiteMapNode(nodeID, url, menuText);

            node.ReferenceName = pageFormulaItem.ContentReferenceName;
            node.ContentID     = pageFormulaItem.ContentID;

            //override the visibility attributes...
            node.SitemapVisible = pageFormulaItem.VisibleOnSitemap;
            node.MenuVisible    = pageFormulaItem.VisibleOnMenu;

            node.ParentNode = parentNode.ParentNode;
            node.PageItemID = parentNode.PageItemID;
            node.ChildNodes = new List <AgilitySiteMapNode>();


            foreach (AgilitySiteMapNode parentChildNode in parentNode.ChildNodes)
            {
                AgilitySiteMapNode childNode = parentChildNode.Copy(urlPath, node);
                node.ChildNodes.Add(childNode);
            }

            return(node);
        }