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


C# Uri.ApplyParameters方法代碼示例

本文整理匯總了C#中System.Uri.ApplyParameters方法的典型用法代碼示例。如果您正苦於以下問題:C# Uri.ApplyParameters方法的具體用法?C# Uri.ApplyParameters怎麽用?C# Uri.ApplyParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Uri的用法示例。


在下文中一共展示了Uri.ApplyParameters方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DoesNotChangeUrlWhenParametersEmpty

            public void DoesNotChangeUrlWhenParametersEmpty()
            {
                var uri = new Uri("https://example.com");

                var uriWithEmptyParameters = uri.ApplyParameters(new Dictionary<string, string>());
                var uriWithNullParameters = uri.ApplyParameters(null);

                Assert.Equal(uri, uriWithEmptyParameters);
                Assert.Equal(uri, uriWithNullParameters);
            }
開發者ID:rajwilkhu,項目名稱:octokit.net,代碼行數:10,代碼來源:UriExtensionsTests.cs

示例2: DoesNotChangePassedInDictionary

            public void DoesNotChangePassedInDictionary()
            {
                var uri = new Uri("https://api.github.com/repositories/1/milestones?state=closed&sort=due_date&direction=asc&page=2");

                var parameters = new Dictionary<string, string> { { "state", "open" }, { "sort", "other" } };

                uri.ApplyParameters(parameters);

                Assert.Equal(2, parameters.Count);
            }
開發者ID:rajwilkhu,項目名稱:octokit.net,代碼行數:10,代碼來源:UriExtensionsTests.cs

示例3: ThrowsExceptionWhenNullValueProvided

            public void ThrowsExceptionWhenNullValueProvided()
            {
                var uri = new Uri("https://example.com");

                var parameters = new Dictionary<string, string>
                {
                    {"foo", null },
                };

                Assert.Throws<ArgumentNullException>(() => uri.ApplyParameters(parameters));
            }
開發者ID:KimCM,項目名稱:octokit.net,代碼行數:11,代碼來源:UriExtensionsTests.cs

示例4: AppendsParametersAsQueryStringToRelativeUri

            public void AppendsParametersAsQueryStringToRelativeUri()
            {
                var uri = new Uri("issues", UriKind.Relative);

                var uriWithParameters = uri.ApplyParameters(new Dictionary<string, string>
                {
                    {"foo", "fooval"},
                    {"bar", "barval"}
                });

                Assert.Equal(new Uri("issues?foo=fooval&bar=barval", UriKind.Relative), uriWithParameters);
            }
開發者ID:rajwilkhu,項目名稱:octokit.net,代碼行數:12,代碼來源:UriExtensionsTests.cs

示例5: AppendsParametersAsQueryString

            public void AppendsParametersAsQueryString()
            {
                var uri = new Uri("https://example.com");

                var uriWithParameters = uri.ApplyParameters(new Dictionary<string, string>
                {
                    {"foo", "foo val"},
                    {"bar", "barval"}
                });

                Assert.Equal(new Uri("https://example.com?foo=foo%20val&bar=barval"), uriWithParameters);
            }
開發者ID:rajwilkhu,項目名稱:octokit.net,代碼行數:12,代碼來源:UriExtensionsTests.cs

示例6: OverwritesExistingParameters

            public void OverwritesExistingParameters()
            {
                var uri = new Uri("https://example.com?crap=crapola");

                var uriWithParameters = uri.ApplyParameters(new Dictionary<string, string>
                {
                    {"foo", "fooval"},
                    {"bar", "barval"}
                });

                Assert.Equal(new Uri("https://example.com?foo=fooval&bar=barval"), uriWithParameters);
            }
開發者ID:ninjanye,項目名稱:octokit.net,代碼行數:12,代碼來源:UriExtensionsTests.cs

示例7: CombinesExistingParametersWithNewParameters

            public void CombinesExistingParametersWithNewParameters()
            {
                var uri = new Uri("https://api.github.com/repositories/1/milestones?state=closed&sort=due_date&direction=asc&page=2");

                var parameters = new Dictionary<string, string> { { "state", "open" }, { "sort", "other"} };

                var actual = uri.ApplyParameters(parameters);

                Assert.True(actual.Query.Contains("state=open"));
                Assert.True(actual.Query.Contains("sort=other"));
                Assert.True(actual.Query.Contains("direction=asc"));
                Assert.True(actual.Query.Contains("page=2"));
            }
開發者ID:rajwilkhu,項目名稱:octokit.net,代碼行數:13,代碼來源:UriExtensionsTests.cs


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