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


C# ISiteMapNode.UsesDefaultUrlResolver方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:Relix1990,项目名称:MvcSiteMapProvider,代码行数:29,代码来源:SiteMapNodeUrlKey.cs

示例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);
                }
            }
        }
开发者ID:nZeus,项目名称:MvcSiteMapProvider,代码行数:54,代码来源:SiteMap.cs


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