Ejemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (this == null)
            {
                return(false);
            }
            IUrlKey objB = obj as IUrlKey;

            if (objB == null)
            {
                return(false);
            }
            if (object.ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (!string.Equals(this.RootRelativeUrl, objB.RootRelativeUrl, StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }
            if (!string.Equals(this.HostName, objB.HostName, StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        protected virtual ISiteMapNode FindSiteMapNodeFromUrlMatch(IUrlKey urlToMatch)
        {
            if (this.urlTable.ContainsKey(urlToMatch))
            {
                return(this.urlTable[urlToMatch]);
            }

            return(null);
        }
Ejemplo n.º 3
0
        protected virtual void AddNodeInternal(ISiteMapNode node, ISiteMapNode parentNode)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            lock (this.synclock)
            {
                IUrlKey url      = null;
                bool    isMvcUrl = string.IsNullOrEmpty(node.UnresolvedUrl) && this.UsesDefaultUrlResolver(node);

                // Only store URLs if they are clickable and are configured using the Url
                // property or provided by a custom URL resolver.
                if (!isMvcUrl && node.Clickable)
                {
                    url = this.siteMapChildStateFactory.CreateUrlKey(node);

                    // Check for duplicates (including matching or empty host names).
                    if (this.urlTable
                        .Where(k => string.Equals(k.Key.RootRelativeUrl, url.RootRelativeUrl, StringComparison.OrdinalIgnoreCase))
                        .Where(k => string.IsNullOrEmpty(k.Key.HostName) || string.IsNullOrEmpty(url.HostName) || string.Equals(k.Key.HostName, url.HostName, StringComparison.OrdinalIgnoreCase))
                        .Count() > 0)
                    {
                        var absoluteUrl = this.urlPath.ResolveUrl(node.UnresolvedUrl, string.IsNullOrEmpty(node.Protocol) ? Uri.UriSchemeHttp : node.Protocol, node.HostName);
                        throw new InvalidOperationException(string.Format(Resources.Messages.MultipleNodesWithIdenticalUrl, absoluteUrl));
                    }
                }

                // Add the key
                string key = node.Key;
                if (this.keyTable.ContainsKey(key))
                {
                    throw new InvalidOperationException(string.Format(Resources.Messages.MultipleNodesWithIdenticalKey, key));
                }
                this.keyTable[key] = node;

                // Add the URL
                if (url != null)
                {
                    this.urlTable[url] = node;
                }

                // Add the parent-child relationship
                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.º 4
0
        protected virtual ISiteMapNode FindSiteMapNodeFromUrlMatch(IUrlKey urlToMatch)
        {
            if (this.urlTable.ContainsKey(urlToMatch))
            {
                return this.urlTable[urlToMatch];
            }

            return null;
        }