本文整理汇总了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 ();
}
示例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;
}
}
}
}
示例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;
}
}
}
}
}