Ejemplo n.º 1
0
        protected virtual string ResolveVirtualPath(ISiteMapNode node)
        {
            var url = node.UnresolvedUrl;

            if (!urlPath.IsAbsoluteUrl(url))
            {
                return(urlPath.MakeVirtualPathAppAbsolute(urlPath.Combine(urlPath.AppDomainAppVirtualPath, url)));
            }
            return(url);
        }
Ejemplo n.º 2
0
 protected virtual void AddNodeInternal(ISiteMapNode node, ISiteMapNode parentNode)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     lock (this.synclock)
     {
         bool   urlPrepared = false;
         bool   urlEncoded  = false;
         string url         = node.Url;
         if (!string.IsNullOrEmpty(url))
         {
             if (node.HasAbsoluteUrl())
             {
                 // This is an external url, so we will encode it
                 url        = urlPath.UrlEncode(url);
                 urlEncoded = true;
             }
             if (urlPath.AppDomainAppVirtualPath != null)
             {
                 if (!urlPath.IsAbsolutePhysicalPath(url))
                 {
                     url = urlPath.MakeVirtualPathAppAbsolute(urlPath.Combine(urlPath.AppDomainAppVirtualPath, url));
                 }
                 if (this.urlTable.ContainsKey(url))
                 {
                     if (urlEncoded)
                     {
                         url = urlPath.UrlDecode(url);
                     }
                     throw new InvalidOperationException(String.Format(Resources.Messages.MultipleNodesWithIdenticalUrl, url));
                 }
             }
             urlPrepared = true;
         }
         string key = node.Key;
         if (this.keyTable.ContainsKey(key))
         {
             throw new InvalidOperationException(String.Format(Resources.Messages.MultipleNodesWithIdenticalKey, key));
         }
         this.keyTable[key] = node;
         if (urlPrepared)
         {
             this.urlTable[url] = node;
         }
         if (parentNode != null)
         {
             this.parentNodeTable[node] = parentNode;
             if (!this.childNodeCollectionTable.ContainsKey(parentNode))
             {
                 this.childNodeCollectionTable[parentNode] = siteMapChildStateFactory.CreateLockableSiteMapNodeCollection(this);
             }
             this.childNodeCollectionTable[parentNode].Add(node);
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Generates the sitemap index elements.
 /// </summary>
 /// <param name="numPages">The number of pages.</param>
 /// <param name="siteMapUrlTemplate">The site map URL template.</param>
 /// <returns>The sitemap index elements.</returns>
 protected virtual IEnumerable <XElement> GenerateSiteMapIndexElements(int numPages, string baseUrl, string siteMapUrlTemplate)
 {
     // Generate elements
     for (int i = 1; i <= numPages; i++)
     {
         var combinedPath = urlPath.Combine(urlPath.AppDomainAppVirtualPath, "~/" + siteMapUrlTemplate.Replace("{page}", i.ToString()));
         var pageUrl      = baseUrl + urlPath.MakeVirtualPathAppAbsolute(combinedPath);
         yield return(new XElement(Ns + "sitemap", new XElement(Ns + "loc", pageUrl)));
     }
 }