当前位置: 首页>>代码示例>>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;未经允许,请勿转载。