本文整理汇总了C#中System.Uri.MakeAppLocalPath方法的典型用法代码示例。如果您正苦于以下问题:C# Uri.MakeAppLocalPath方法的具体用法?C# Uri.MakeAppLocalPath怎么用?C# Uri.MakeAppLocalPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Uri
的用法示例。
在下文中一共展示了Uri.MakeAppLocalPath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_support_site_root_without_trailing_slash
public void Should_support_site_root_without_trailing_slash()
{
// Given
var uri = new Uri("http://host/");
// When
string result = uri.MakeAppLocalPath(new Uri("http://host"));
// Then
result.ShouldEqual("/");
}
示例2: Should_support_extended_site_root
public void Should_support_extended_site_root()
{
// Given
var uri = new Uri("http://host/");
// When
string result = uri.MakeAppLocalPath(new Uri("http://host/rel/file"));
// Then
result.ShouldEqual("/rel/file");
}
示例3: Should_return_path_with_same_casing_as_full_uri
public void Should_return_path_with_same_casing_as_full_uri()
{
// Given
var uri = new Uri("http://host/base/");
// When
string result = uri.MakeAppLocalPath(new Uri("http://host/base/ReL"));
// Then
result.ShouldEqual("/ReL");
}
示例4: Should_return_root_path_without_trailing_slash_as_slash
public void Should_return_root_path_without_trailing_slash_as_slash()
{
// Given
var uri = new Uri("http://host/base/");
// When
string result = uri.MakeAppLocalPath(new Uri("http://host/base"));
// Then
result.ShouldEqual("/");
}
示例5: Should_return_path_as_local_path
public void Should_return_path_as_local_path()
{
// Given
var uri = new Uri("http://host/base/");
// When
string result = uri.MakeAppLocalPath(new Uri("http://host/base/rel"));
// Then
result.ShouldEqual("/rel");
}
示例6: ConvertRequest
private Request ConvertRequest(Uri baseUri, HttpListenerRequest httpRequest)
{
var expectedRequestLength = GetExpectedRequestLength(ConvertToDictionary(httpRequest.Headers));
var url = new Url
{
Scheme = httpRequest.Url.Scheme,
HostName = httpRequest.Url.Host,
Port = httpRequest.Url.IsDefaultPort ? null : (int?)httpRequest.Url.Port,
BasePath = baseUri.AbsolutePath.TrimEnd('/'),
Path = baseUri.MakeAppLocalPath(httpRequest.Url),
Query = httpRequest.Url.Query,
};
var fieldCount = httpRequest.ProtocolVersion.Major == 2 ? 1 : 2;
var protocolVersion = string.Format("HTTP/{0}", httpRequest.ProtocolVersion.ToString(fieldCount));
byte[] certificate = null;
if (httpRequest.IsSecureConnection)
{
var x509Certificate = httpRequest.GetClientCertificate();
if (x509Certificate != null)
{
certificate = x509Certificate.RawData;
}
}
return new Request(
httpRequest.HttpMethod,
url,
RequestStream.FromStream(httpRequest.InputStream, expectedRequestLength, false),
ConvertToDictionary(httpRequest.Headers),
(httpRequest.RemoteEndPoint != null) ? httpRequest.RemoteEndPoint.Address.ToString() : null,
protocolVersion,
certificate);
}
示例7: Should_return_path_with_case_insensitive_base_uri_comparison
public void Should_return_path_with_case_insensitive_base_uri_comparison()
{
// Given
var uri = new Uri("http://host/base/");
// When
string result = uri.MakeAppLocalPath(new Uri("http://host/Base/rel"));
// Then
result.ShouldEqual("/rel");
}