当前位置: 首页>>代码示例>>C#>>正文


C# SiteMapProvider.GetRootNodeCore方法代码示例

本文整理汇总了C#中System.Web.SiteMapProvider.GetRootNodeCore方法的典型用法代码示例。如果您正苦于以下问题:C# SiteMapProvider.GetRootNodeCore方法的具体用法?C# SiteMapProvider.GetRootNodeCore怎么用?C# SiteMapProvider.GetRootNodeCore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.SiteMapProvider的用法示例。


在下文中一共展示了SiteMapProvider.GetRootNodeCore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetRootNodeCoreFromProvider

		protected static SiteMapNode GetRootNodeCoreFromProvider (SiteMapProvider provider)
		{
			return provider.GetRootNodeCore ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:4,代码来源:SiteMapProvider.cs

示例2: EnsureChildSiteMapProviderUpToDate

        private void EnsureChildSiteMapProviderUpToDate(SiteMapProvider childProvider) {
            SiteMapNode oldNode = (SiteMapNode)ChildProviderTable[childProvider];

            SiteMapNode newNode = childProvider.GetRootNodeCore();
            if (newNode == null) {
                throw new ProviderException(SR.GetString(SR.XmlSiteMapProvider_invalid_sitemapnode_returned, childProvider.Name));
            }

            // child providers have been updated.
            if (!oldNode.Equals(newNode)) {

                // If the child provider table has been updated, simply return null.
                // This will happen when the current provider's sitemap file is changed or Clear() is called;
                if (oldNode == null) {
                    return;
                }

                lock (_lock) {
                    oldNode = (SiteMapNode)ChildProviderTable[childProvider];
                    // If the child provider table has been updated, simply return null. See above.
                    if (oldNode == null) {
                        return;
                    }

                    newNode = childProvider.GetRootNodeCore();
                    if (newNode == null) {
                        throw new ProviderException(SR.GetString(SR.XmlSiteMapProvider_invalid_sitemapnode_returned, childProvider.Name));
                    }

                    if (!oldNode.Equals(newNode)) {

                        // If the current provider does not contain any nodes but one child provider
                        // ie. _siteMapNode == oldNode
                        // the oldNode needs to be removed from Url table and the new node will be added.
                        if (_siteMapNode.Equals(oldNode)) {
                            UrlTable.Remove(oldNode.Url);
                            KeyTable.Remove(oldNode.Key);

                            UrlTable.Add(newNode.Url, newNode);
                            KeyTable.Add(newNode.Key, newNode);

                            _siteMapNode = newNode;
                        }

                        // First find the parent node
                        SiteMapNode parent = (SiteMapNode)ParentNodeTable[oldNode];

                        // parent is null when the provider does not contain any static nodes, ie.
                        // it only contains definition to include one child provider.
                        if (parent != null) {
                            // Update the child nodes table
                            SiteMapNodeCollection list = (SiteMapNodeCollection)ChildNodeCollectionTable[parent];

                            // Add the newNode to where the oldNode is within parent node's collection.
                            int index = list.IndexOf(oldNode);
                            if (index != -1) {
                                list.Remove(oldNode);
                                list.Insert(index, newNode);
                            }
                            else {
                                list.Add(newNode);
                            }

                            // Update the parent table
                            ParentNodeTable[newNode] = parent;
                            ParentNodeTable.Remove(oldNode);

                            // Update the Url table
                            UrlTable.Remove(oldNode.Url);
                            KeyTable.Remove(oldNode.Key);

                            UrlTable.Add(newNode.Url, newNode);
                            KeyTable.Add(newNode.Key, newNode);
                        }
                        else {
                            // Notify the parent provider to update its child provider collection.
                            XmlSiteMapProvider provider = ParentProvider as XmlSiteMapProvider;
                            if (provider != null) {
                                provider.EnsureChildSiteMapProviderUpToDate(this);
                            }
                        }

                        // Update provider nodes;
                        ChildProviderTable[childProvider] = newNode;
                        _childProviderList = null;
                    }
                }
            }
        }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:89,代码来源:XmlSiteMapProvider.cs

示例3: EnsureChildSiteMapProviderUpToDate

 private void EnsureChildSiteMapProviderUpToDate(SiteMapProvider childProvider)
 {
     SiteMapNode node = (SiteMapNode) this.ChildProviderTable[childProvider];
     SiteMapNode rootNodeCore = childProvider.GetRootNodeCore();
     if (rootNodeCore == null)
     {
         throw new ProviderException(System.Web.SR.GetString("XmlSiteMapProvider_invalid_sitemapnode_returned", new object[] { childProvider.Name }));
     }
     if (!node.Equals(rootNodeCore) && (node != null))
     {
         lock (base._lock)
         {
             node = (SiteMapNode) this.ChildProviderTable[childProvider];
             if (node != null)
             {
                 rootNodeCore = childProvider.GetRootNodeCore();
                 if (rootNodeCore == null)
                 {
                     throw new ProviderException(System.Web.SR.GetString("XmlSiteMapProvider_invalid_sitemapnode_returned", new object[] { childProvider.Name }));
                 }
                 if (!node.Equals(rootNodeCore))
                 {
                     if (this._siteMapNode.Equals(node))
                     {
                         base.UrlTable.Remove(node.Url);
                         base.KeyTable.Remove(node.Key);
                         base.UrlTable.Add(rootNodeCore.Url, rootNodeCore);
                         base.KeyTable.Add(rootNodeCore.Key, rootNodeCore);
                         this._siteMapNode = rootNodeCore;
                     }
                     SiteMapNode node3 = (SiteMapNode) base.ParentNodeTable[node];
                     if (node3 != null)
                     {
                         SiteMapNodeCollection nodes = (SiteMapNodeCollection) base.ChildNodeCollectionTable[node3];
                         int index = nodes.IndexOf(node);
                         if (index != -1)
                         {
                             nodes.Remove(node);
                             nodes.Insert(index, rootNodeCore);
                         }
                         else
                         {
                             nodes.Add(rootNodeCore);
                         }
                         base.ParentNodeTable[rootNodeCore] = node3;
                         base.ParentNodeTable.Remove(node);
                         base.UrlTable.Remove(node.Url);
                         base.KeyTable.Remove(node.Key);
                         base.UrlTable.Add(rootNodeCore.Url, rootNodeCore);
                         base.KeyTable.Add(rootNodeCore.Key, rootNodeCore);
                     }
                     else
                     {
                         XmlSiteMapProvider parentProvider = this.ParentProvider as XmlSiteMapProvider;
                         if (parentProvider != null)
                         {
                             parentProvider.EnsureChildSiteMapProviderUpToDate(this);
                         }
                     }
                     this.ChildProviderTable[childProvider] = rootNodeCore;
                     this._childProviderList = null;
                 }
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:66,代码来源:XmlSiteMapProvider.cs


注:本文中的System.Web.SiteMapProvider.GetRootNodeCore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。