本文整理匯總了C#中System.Uri.NormalizeLocalhost方法的典型用法代碼示例。如果您正苦於以下問題:C# Uri.NormalizeLocalhost方法的具體用法?C# Uri.NormalizeLocalhost怎麽用?C# Uri.NormalizeLocalhost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Uri
的用法示例。
在下文中一共展示了Uri.NormalizeLocalhost方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: can_handle_localhost_consistently
public void can_handle_localhost_consistently()
{
var uri = new Uri("http://lOcAlHoSt/blahdee");
var normalizedUri = uri.NormalizeLocalhost();
normalizedUri.ToString().ShouldBe("http://{0}/blahdee".ToFormat(System.Environment.MachineName.ToLower()));
}
示例2: GetRoutedEndpoint
public Endpoint GetRoutedEndpoint(Uri endpoint)
{
Uri newEndpoint = null;
mapping.Read(reader => reader.TryGetValue(endpoint.NormalizeLocalhost(), out newEndpoint));
return new Endpoint
{
Uri = newEndpoint ?? endpoint
};
}
示例3: can_handle_localhost_consistently_2
public void can_handle_localhost_consistently_2()
{
var router = new EndpointRouter();
var uri = new Uri("http://127.0.0.1/blahdee");
var normalizedUri = uri.NormalizeLocalhost();
var routeFrom = new Uri("http://remotehost/zippee");
router.RemapEndpoint(routeFrom, uri);
Assert.Equal(normalizedUri, router.GetRoutedEndpoint(routeFrom).Uri);
}
示例4: can_handle_localhost_consistently
public void can_handle_localhost_consistently()
{
var router = new EndpointRouter();
var uri = new Uri("http://lOcAlHoSt/blahdee");
var normalizedUri = uri.NormalizeLocalhost();
var routeTo = new Uri("http://remotehost/zippee");
router.RemapEndpoint(uri, routeTo);
Assert.Equal(routeTo, router.GetRoutedEndpoint(normalizedUri).Uri);
Assert.Equal(routeTo, router.GetRoutedEndpoint(uri).Uri);
}
示例5: RemapEndpoint
public void RemapEndpoint(Uri originalEndpoint, Uri newEndpoint)
{
mapping.Write(writer => writer.Add(originalEndpoint.NormalizeLocalhost(), newEndpoint.NormalizeLocalhost()));
}