Пример #1
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);
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Gets the absolute URL for a node.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns>The absolute URL.</returns>
        protected virtual string GetAbsoluteUrl(ISiteMapNode node)
        {
            var nodeUrl = node.Url;
            var result  = nodeUrl;

            if (!node.HasAbsoluteUrl())
            {
                result = this.BaseUrl + nodeUrl;
            }
            return(result);
        }
Пример #3
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);
         }
     }
 }
 /// <summary>
 /// Gets the absolute URL for a node.
 /// </summary>
 /// <param name="node">The node.</param>
 /// <returns>The absolute URL.</returns>
 protected virtual string GetAbsoluteUrl(ISiteMapNode node)
 {
     var nodeUrl = node.Url;
     var result = nodeUrl;
     if (!node.HasAbsoluteUrl())
     {
         result = this.BaseUrl + nodeUrl;
     }
     return result;
 }