protected internal override void AddNode(SiteMapNode node, SiteMapNode parentNode)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     if (parentNode == null)
     {
         throw new ArgumentNullException("parentNode");
     }
     SiteMapProvider provider = node.Provider;
     SiteMapProvider provider2 = parentNode.Provider;
     if (provider != this)
     {
         throw new ArgumentException(System.Web.SR.GetString("XmlSiteMapProvider_cannot_add_node", new object[] { node.ToString() }), "node");
     }
     if (provider2 != this)
     {
         throw new ArgumentException(System.Web.SR.GetString("XmlSiteMapProvider_cannot_add_node", new object[] { parentNode.ToString() }), "parentNode");
     }
     lock (base._lock)
     {
         this.RemoveNode(node);
         this.AddNodeInternal(node, parentNode, null);
     }
 }
Esempio n. 2
0
        protected virtual void AddProvider(string providerName, SiteMapNode parentNode)
        {
            if (parentNode == null)
            {
                throw new ArgumentNullException("parentNode");
            }

            if (parentNode.Provider != this)
            {
                throw new ArgumentException(SR.GetString(SR.XmlSiteMapProvider_cannot_add_node, parentNode.ToString()), "parentNode");
            }

            SiteMapNode node = GetNodeFromProvider(providerName);

            AddNodeInternal(node, parentNode, null);
        }
Esempio n. 3
0
        protected internal override void AddNode(SiteMapNode node, SiteMapNode parentNode)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (parentNode == null)
            {
                throw new ArgumentNullException("parentNode");
            }

            SiteMapProvider ownerProvider       = node.Provider;
            SiteMapProvider parentOwnerProvider = parentNode.Provider;

            if (ownerProvider != this)
            {
                throw new ArgumentException(SR.GetString(SR.XmlSiteMapProvider_cannot_add_node, node.ToString()), "node");
            }

            if (parentOwnerProvider != this)
            {
                throw new ArgumentException(SR.GetString(SR.XmlSiteMapProvider_cannot_add_node, parentNode.ToString()), "parentNode");
            }

            lock (_lock) {
                // First remove it from its current location.
                RemoveNode(node);
                AddNodeInternal(node, parentNode, null);
            }
        }
Esempio n. 4
0
        protected internal override void RemoveNode(SiteMapNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            SiteMapProvider ownerProvider = node.Provider;

            if (ownerProvider != this)
            {
                // Only nodes defined in this provider tree can be removed.
                SiteMapProvider parentProvider = ownerProvider.ParentProvider;
                while (parentProvider != this)
                {
                    if (parentProvider == null)
                    {
                        // Cannot remove nodes defined in other providers
                        throw new InvalidOperationException(
                                  SR.GetString(SR.XmlSiteMapProvider_cannot_remove_node, node.ToString(),
                                               this.Name, ownerProvider.Name));
                    }

                    parentProvider = parentProvider.ParentProvider;
                }
            }

            if (node.Equals(ownerProvider.GetRootNodeCore()))
            {
                throw new InvalidOperationException(SR.GetString(SR.SiteMapProvider_cannot_remove_root_node));
            }

            if (ownerProvider != this)
            {
                // Remove node from the owner provider.
                ownerProvider.RemoveNode(node);
            }

            base.RemoveNode(node);
        }
 /// <summary>
 /// Removes the specified <see cref="T:System.Web.SiteMapNode"/> object from all site map node collections that are tracked by the site map provider.
 /// </summary>
 /// <param name="node">The site map node to remove from the site map node collections.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///   <paramref name="node"/> is null.
 ///   </exception>
 protected override void RemoveNode(SiteMapNode node)
 {
     if (node == null)
         throw new ArgumentNullException("node");
     var provider = node.Provider;
     if (provider != this)
         for (var parentProvider = provider.ParentProvider; parentProvider != this; parentProvider = parentProvider.ParentProvider)
             if (parentProvider == null)
                 throw new InvalidOperationException(string.Format("StaticSiteMapProviderEx_cannot_remove_node", node.ToString(), Name, provider.Name));
     if (node.Equals(provider.RootNode))
         throw new InvalidOperationException("StaticSiteMapProviderEx_cannot_remove_root_node");
     if (provider != this)
         _providerRemoveNode.Invoke(provider, new[] { node });
     base.RemoveNode(node);
 }
 /// <summary>
 /// Adds the provider.
 /// </summary>
 /// <param name="providerName">Name of the provider.</param>
 /// <param name="parentNode">The parent node.</param>
 /// <param name="rebaseAction">The rebase action.</param>
 public void AddProvider(string providerName, SiteMapNode parentNode, Action<SiteMapNode> rebaseAction)
 {
     if (parentNode == null)
         throw new ArgumentNullException("parentNode");
     if (parentNode.Provider != this)
         throw new ArgumentException(string.Format("StaticSiteMapProviderEx_cannot_add_node", parentNode.ToString()), "parentNode");
     var rootNode = GetNodeFromProvider(providerName, rebaseAction);
     AddNode(rootNode, parentNode);
 }
Esempio n. 7
0
        protected internal override void RemoveNode(SiteMapNode node) {
            if (node == null) {
                throw new ArgumentNullException("node");
            }

            SiteMapProvider ownerProvider = node.Provider;

            if (ownerProvider != this) {

                // Only nodes defined in this provider tree can be removed.
                SiteMapProvider parentProvider = ownerProvider.ParentProvider;
                while (parentProvider != this) {
                    if (parentProvider == null) {
                        // Cannot remove nodes defined in other providers
                        throw new InvalidOperationException(
                            SR.GetString(SR.XmlSiteMapProvider_cannot_remove_node, node.ToString(), 
                            this.Name, ownerProvider.Name));
                    }

                    parentProvider = parentProvider.ParentProvider;
                }
            }

            if (node.Equals(ownerProvider.GetRootNodeCore())) {
                throw new InvalidOperationException(SR.GetString(SR.SiteMapProvider_cannot_remove_root_node));
            }

            if (ownerProvider != this) {
                // Remove node from the owner provider.
                ownerProvider.RemoveNode(node);
            }

            base.RemoveNode(node);
        }
Esempio n. 8
0
        protected virtual void AddProvider(string providerName, SiteMapNode parentNode) {
            if (parentNode == null) {
                throw new ArgumentNullException("parentNode");
            }

            if (parentNode.Provider != this) {
                throw new ArgumentException(SR.GetString(SR.XmlSiteMapProvider_cannot_add_node, parentNode.ToString()), "parentNode");
            }

            SiteMapNode node = GetNodeFromProvider(providerName);
            AddNodeInternal(node, parentNode, null);
        }
Esempio n. 9
0
        protected internal override void AddNode(SiteMapNode node, SiteMapNode parentNode) {
            if (node == null) {
                throw new ArgumentNullException("node");
            }

            if (parentNode == null) {
                throw new ArgumentNullException("parentNode");
            }

            SiteMapProvider ownerProvider = node.Provider;
            SiteMapProvider parentOwnerProvider = parentNode.Provider;

            if (ownerProvider != this) {
                throw new ArgumentException(SR.GetString(SR.XmlSiteMapProvider_cannot_add_node, node.ToString()), "node");
            }

            if (parentOwnerProvider != this) {
                throw new ArgumentException(SR.GetString(SR.XmlSiteMapProvider_cannot_add_node, parentNode.ToString()), "parentNode");
            }

            lock (_lock) {
                // First remove it from its current location.
                RemoveNode(node);
                AddNodeInternal(node, parentNode, null);
            }
        }
Esempio n. 10
0
        public void AddProvider(string providerName, SiteMapNode parentNode, Action <SiteMapNode> rebaseAction)
        {
            if (parentNode == null)
            {
                throw new ArgumentNullException("parentNode");
            }
            if (parentNode.Provider != this)
            {
                throw new ArgumentException(string.Format("StaticSiteMapProviderEx_cannot_add_node", parentNode.ToString()), "parentNode");
            }
            var rootNode = GetNodeFromProvider(providerName, rebaseAction);

            AddNode(rootNode, parentNode);
        }
Esempio n. 11
0
        protected override void RemoveNode(SiteMapNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            var provider = node.Provider;

            if (provider != this)
            {
                for (var parentProvider = provider.ParentProvider; parentProvider != this; parentProvider = parentProvider.ParentProvider)
                {
                    if (parentProvider == null)
                    {
                        throw new InvalidOperationException(string.Format("StaticSiteMapProviderEx_cannot_remove_node", node.ToString(), Name, provider.Name));
                    }
                }
            }
            if (node.Equals(provider.RootNode))
            {
                throw new InvalidOperationException("StaticSiteMapProviderEx_cannot_remove_root_node");
            }
            if (provider != this)
            {
                _providerRemoveNode.Invoke(provider, new[] { node });
            }
            base.RemoveNode(node);
        }
Esempio n. 12
0
        protected internal override void RemoveNode(SiteMapNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            SiteMapProvider provider = node.Provider;

            if (provider != this)
            {
                for (SiteMapProvider provider2 = provider.ParentProvider; provider2 != this; provider2 = provider2.ParentProvider)
                {
                    if (provider2 == null)
                    {
                        throw new InvalidOperationException(System.Web.SR.GetString("XmlSiteMapProvider_cannot_remove_node", new object[] { node.ToString(), this.Name, provider.Name }));
                    }
                }
            }
            if (node.Equals(provider.GetRootNodeCore()))
            {
                throw new InvalidOperationException(System.Web.SR.GetString("SiteMapProvider_cannot_remove_root_node"));
            }
            if (provider != this)
            {
                provider.RemoveNode(node);
            }
            base.RemoveNode(node);
        }
Esempio n. 13
0
        protected internal override void AddNode(SiteMapNode node, SiteMapNode parentNode)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (parentNode == null)
            {
                throw new ArgumentNullException("parentNode");
            }
            SiteMapProvider provider  = node.Provider;
            SiteMapProvider provider2 = parentNode.Provider;

            if (provider != this)
            {
                throw new ArgumentException(System.Web.SR.GetString("XmlSiteMapProvider_cannot_add_node", new object[] { node.ToString() }), "node");
            }
            if (provider2 != this)
            {
                throw new ArgumentException(System.Web.SR.GetString("XmlSiteMapProvider_cannot_add_node", new object[] { parentNode.ToString() }), "parentNode");
            }
            lock (base._lock)
            {
                this.RemoveNode(node);
                this.AddNodeInternal(node, parentNode, null);
            }
        }
Esempio n. 14
0
        protected virtual void AddProvider(string providerName, SiteMapNode parentNode)
        {
            if (parentNode == null)
            {
                throw new ArgumentNullException("parentNode");
            }
            if (parentNode.Provider != this)
            {
                throw new ArgumentException(System.Web.SR.GetString("XmlSiteMapProvider_cannot_add_node", new object[] { parentNode.ToString() }), "parentNode");
            }
            SiteMapNode nodeFromProvider = this.GetNodeFromProvider(providerName);

            this.AddNodeInternal(nodeFromProvider, parentNode, null);
        }
 protected internal override void RemoveNode(SiteMapNode node)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     SiteMapProvider provider = node.Provider;
     if (provider != this)
     {
         for (SiteMapProvider provider2 = provider.ParentProvider; provider2 != this; provider2 = provider2.ParentProvider)
         {
             if (provider2 == null)
             {
                 throw new InvalidOperationException(System.Web.SR.GetString("XmlSiteMapProvider_cannot_remove_node", new object[] { node.ToString(), this.Name, provider.Name }));
             }
         }
     }
     if (node.Equals(provider.GetRootNodeCore()))
     {
         throw new InvalidOperationException(System.Web.SR.GetString("SiteMapProvider_cannot_remove_root_node"));
     }
     if (provider != this)
     {
         provider.RemoveNode(node);
     }
     base.RemoveNode(node);
 }
 protected virtual void AddProvider(string providerName, SiteMapNode parentNode)
 {
     if (parentNode == null)
     {
         throw new ArgumentNullException("parentNode");
     }
     if (parentNode.Provider != this)
     {
         throw new ArgumentException(System.Web.SR.GetString("XmlSiteMapProvider_cannot_add_node", new object[] { parentNode.ToString() }), "parentNode");
     }
     SiteMapNode nodeFromProvider = this.GetNodeFromProvider(providerName);
     this.AddNodeInternal(nodeFromProvider, parentNode, null);
 }