本文整理汇总了C#中UriTemplate.Match方法的典型用法代码示例。如果您正苦于以下问题:C# UriTemplate.Match方法的具体用法?C# UriTemplate.Match怎么用?C# UriTemplate.Match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UriTemplate
的用法示例。
在下文中一共展示了UriTemplate.Match方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: the_template_matches_when_query_strings_are_present
public void the_template_matches_when_query_strings_are_present()
{
var template = new UriTemplate("/temperature?unit={unit}");
var match = template.Match(new Uri("http://localhost"), new Uri("http://localhost/temperature"));
match.ShouldNotBeNull();
match.PathSegmentVariables.Count.ShouldBe(0);
match.QueryParameters.Count.ShouldBe(1);
}
示例2: a_url_with_extra_query_string_parameters_will_match
public void a_url_with_extra_query_string_parameters_will_match()
{
var template = new UriTemplate("/test?q={searchTerm}&p={pageNumber}&s={pageSize}");
UriTemplateMatch match = template.Match(new Uri("http://localhost/"), new Uri("http://localhost/test?q=test&p=1&s=10&contentType=json"));
match.ShouldNotBeNull();
}
示例3: the_query_parameters_should_be_case_insensitive
public void the_query_parameters_should_be_case_insensitive()
{
var template = new UriTemplate("/test?page={page}");
var match = template.Match(new Uri("http://localhost"), new Uri("http://localhost/test?pAgE=2"));
match.ShouldNotBeNull();
match.QueryStringVariables.Count.ShouldBe(1);
match.QueryStringVariables["PAGE"].ShouldBe("2");
}
示例4: a_url_different_by_last_letter_to_query_parameters_should_not_match
public void a_url_different_by_last_letter_to_query_parameters_should_not_match()
{
var template = new UriTemplate("/test?query1={test}&query2={test2}");
var match = template.Match(new Uri("http://localhost"), new Uri("http://localhost/test?query1=test1&query3=test2"));
match.ShouldBeNull();
}
示例5: a_url_matching_three_query_string_parameters_will_match
public void a_url_matching_three_query_string_parameters_will_match()
{
var table = new UriTemplate("/test?q={searchTerm}&p={pageNumber}&s={pageSize}");
UriTemplateMatch match = table.Match(new Uri("http://localhost"), new Uri("http://localhost/test?q=&p=1&s=10"));
match.ShouldNotBeNull();
match.QueryParameters["searchTerm"].ShouldBe(string.Empty);
match.QueryParameters["pageNumber"].ShouldBe("1");
match.QueryParameters["pageSize"].ShouldBe("10");
}
示例6: a_url_matching_multiple_query_parameters_should_match
public void a_url_matching_multiple_query_parameters_should_match()
{
var template = new UriTemplate("/test?query1={test}&query2={test2}");
var match = template.Match(new Uri("http://localhost"), new Uri("http://localhost/test?query1=test1&query2=test2"));
match.ShouldNotBeNull();
}
示例7: a_url_not_matching_a_literal_query_string_will_not_match
public void a_url_not_matching_a_literal_query_string_will_not_match()
{
var table = new UriTemplate("/test?query=literal");
UriTemplateMatch match = table.Match(new Uri("http://localhost"), new Uri("http://localhost/test?query=notliteral"));
match.ShouldBeNull();
}
示例8: a_url_matching_result_in_the_query_value_variable_being_set
public void a_url_matching_result_in_the_query_value_variable_being_set()
{
var table = new UriTemplate("/test?query={queryValue}");
UriTemplateMatch match = table.Match(new Uri("http://localhost"), new Uri("http://localhost/test?query=search"));
match.ShouldNotBeNull();
match.QueryParameters["queryValue"].ShouldBe("search");
}
示例9: matching_urls_with_different_host_names_returns_no_match
public void matching_urls_with_different_host_names_returns_no_match()
{
var table = new UriTemplate("/temp");
table.Match(new Uri("http://localhost"), new Uri("http://notlocalhost/temp")).ShouldBeNull();
}
示例10: bound_query_params_should_be_escaped
public void bound_query_params_should_be_escaped()
{
const string searchTerm = "test $&+,/ test";
var encodedString = HttpUtility.UrlEncode(searchTerm);
var template = new UriTemplate("/test?q={searchTerm}");
var match = template.Match(new Uri("http://localhost"), new Uri("http://localhost/test?q=" + encodedString));
match.ShouldNotBeNull();
match.BoundQueryParameters.Count.ShouldBe(1);
match.BoundQueryParameters["searchTerm"].ShouldBe(searchTerm);
}