本文整理汇总了C#中ISiteMapNode.UsesDefaultUrlResolver方法的典型用法代码示例。如果您正苦于以下问题:C# ISiteMapNode.UsesDefaultUrlResolver方法的具体用法?C# ISiteMapNode.UsesDefaultUrlResolver怎么用?C# ISiteMapNode.UsesDefaultUrlResolver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISiteMapNode
的用法示例。
在下文中一共展示了ISiteMapNode.UsesDefaultUrlResolver方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SiteMapNodeUrlKey
public SiteMapNodeUrlKey(
ISiteMapNode node,
IUrlPath urlPath
)
: base(urlPath)
{
if (node == null)
throw new ArgumentNullException("node");
this.node = node;
// Host name in absolute URL overrides this one.
this.hostName = node.HostName;
// Fixes #322 - If using a custom URL resolver, we need to account for the case that
// the URL will be provided by the resolver instead of specified explicitly.
if (!string.IsNullOrEmpty(node.UnresolvedUrl))
{
this.SetUrlValues(node.UnresolvedUrl);
}
else if (!node.UsesDefaultUrlResolver())
{
// For a custom URL resolver, if the unresolved URL property
// is not set use the one returned from the URL resolver.
// This ensures URLs that are unidentifiable by MVC can still
// be matched by URL.
this.SetUrlValues(node.Url);
}
}
示例2: AddNodeInternal
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) && node.UsesDefaultUrlResolver();
// 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);
}
}
}