當前位置: 首頁>>代碼示例>>C#>>正文


C# Uri.MakeAppLocalPath方法代碼示例

本文整理匯總了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("/");
        }
開發者ID:JulianRooze,項目名稱:Nancy,代碼行數:11,代碼來源:MakeAppLocalPathFixture.cs

示例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");
        }
開發者ID:JulianRooze,項目名稱:Nancy,代碼行數:11,代碼來源:MakeAppLocalPathFixture.cs

示例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");
        }
開發者ID:JulianRooze,項目名稱:Nancy,代碼行數:11,代碼來源:MakeAppLocalPathFixture.cs

示例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("/");
        }
開發者ID:JulianRooze,項目名稱:Nancy,代碼行數:11,代碼來源:MakeAppLocalPathFixture.cs

示例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");
        }
開發者ID:JulianRooze,項目名稱:Nancy,代碼行數:11,代碼來源:MakeAppLocalPathFixture.cs

示例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);
        }
開發者ID:gaochundong,項目名稱:Happer,代碼行數:36,代碼來源:Engine.cs

示例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");
        }
開發者ID:JulianRooze,項目名稱:Nancy,代碼行數:11,代碼來源:MakeAppLocalPathFixture.cs


注:本文中的System.Uri.MakeAppLocalPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。