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