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