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


C# Uri.NormalizedHost方法代码示例

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


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

示例1: GetHttpTransportManager

        internal HostedHttpTransportManager GetHttpTransportManager(Uri uri)
        {
            if (ServiceHostingEnvironment.MultipleSiteBindingsEnabled)
            {
                Fx.Assert(transportManagerDirectory.Count == 1, "There should be only one TM in this mode");
                return transportManagerDirectory[0];
            }

            // Optimized common cases without having to create an enumerator.
            switch (this.transportManagerDirectory.Count)
            {
                case 0:
                    return null;

                case 1:
                    {
                        HostedHttpTransportManager manager = this.transportManagerDirectory[0];

                        if (manager.Port == uri.Port &&
                            (string.Compare(manager.Scheme, uri.Scheme, StringComparison.OrdinalIgnoreCase) == 0) &&
                            (manager.HostNameComparisonMode != HostNameComparisonMode.Exact ||
                            string.Compare(manager.ListenUri.Host, uri.NormalizedHost(), StringComparison.OrdinalIgnoreCase) == 0))
                        {
                            return manager;
                        }
                        return null;
                    }

                default:
                    {
                        HostedHttpTransportManager foundTransportManager = null;
                        HostedHttpTransportManager weakTransportManager = null;

                        string scheme = uri.Scheme;
                        int port = uri.Port;
                        string host = null;

                        foreach (HostedHttpTransportManager manager in this.transportManagerDirectory)
                        {
                            if (manager.Port == port &&
                                string.Compare(manager.Scheme, scheme, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                if (manager.HostNameComparisonMode == HostNameComparisonMode.StrongWildcard)
                                {
                                    return manager;
                                }

                                if (manager.HostNameComparisonMode == HostNameComparisonMode.WeakWildcard)
                                {
                                    weakTransportManager = manager;
                                }

                                if ((manager.HostNameComparisonMode == HostNameComparisonMode.Exact) &&
                                    (string.Compare(manager.Host, host ?? (host = uri.NormalizedHost()),
                                    StringComparison.OrdinalIgnoreCase) == 0))
                                {
                                    foundTransportManager = manager;
                                }
                            }
                        }

                        return foundTransportManager ?? weakTransportManager;
                    }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:65,代码来源:HttpHostedTransportConfiguration.cs


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