本文整理汇总了C#中System.UriTemplate.Expand方法的典型用法代码示例。如果您正苦于以下问题:C# UriTemplate.Expand方法的具体用法?C# UriTemplate.Expand怎么用?C# UriTemplate.Expand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.UriTemplate
的用法示例。
在下文中一共展示了UriTemplate.Expand方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultipleExpandVarArgs
public void MultipleExpandVarArgs()
{
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
Uri result = template.Expand("2", 21);
result = template.Expand(1, "42");
Assert.AreEqual(new Uri("http://example.com/hotels/1/bookings/42"), result, "Invalid expanded template");
}
示例2: ExpandVarArgsDuplicateVariables
public void ExpandVarArgsDuplicateVariables()
{
UriTemplate template = new UriTemplate("http://example.com/order/{c}/{c}/{c}");
Assert.AreEqual(new string[] { "c" }, template.VariableNames, "Invalid variable names");
Uri result = template.Expand("cheeseburger");
Assert.AreEqual(new Uri("http://example.com/order/cheeseburger/cheeseburger/cheeseburger"), result, "Invalid expanded template");
}
示例3: ExpandDictionaryInvalidAmountVariables
public void ExpandDictionaryInvalidAmountVariables()
{
IDictionary<string, object> uriVariables = new Dictionary<string, object>(2);
uriVariables.Add("hotel", 1);
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
template.Expand(uriVariables);
}
示例4: ExpandVarArgs
public void ExpandVarArgs()
{
// absolute
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
Uri result = template.Expand("1", "42");
Assert.AreEqual(new Uri("http://example.com/hotels/1/bookings/42"), result, "Invalid expanded template");
// relative
template = new UriTemplate("/hotels/{hotel}/bookings/{booking}");
result = template.Expand("1", "42");
Assert.AreEqual(new Uri("/hotels/1/bookings/42", UriKind.Relative), result, "Invalid expanded template");
}
示例5: ExpandDictionary
public void ExpandDictionary()
{
IDictionary<string, object> uriVariables = new Dictionary<string, object>(2);
uriVariables.Add("booking", "42");
uriVariables.Add("hotel", 1);
// absolute
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
Uri result = template.Expand(uriVariables);
Assert.AreEqual(new Uri("http://example.com/hotels/1/bookings/42"), result, "Invalid expanded template");
// relative
template = new UriTemplate("hotels/{hotel}/bookings/{booking}");
result = template.Expand(uriVariables);
Assert.AreEqual(new Uri("hotels/1/bookings/42", UriKind.Relative), result, "Invalid expanded template");
}
示例6: ExpandEncoded
public void ExpandEncoded()
{
UriTemplate template = new UriTemplate("http://example.com/hotel list/{hotel}");
Uri result = template.Expand("Z\u00fcrich");
Assert.AreEqual(new Uri("http://example.com/hotel%20list/Z%C3%BCrich"), result, "Invalid expanded template");
}
示例7: MultipleExpandDictionary
public void MultipleExpandDictionary()
{
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
IDictionary<string, object> uriVariables = new Dictionary<string, object>(2);
uriVariables.Add("booking", 21);
uriVariables.Add("hotel", "2");
Uri result = template.Expand(uriVariables);
uriVariables = new Dictionary<string, object>(2);
uriVariables.Add("booking", "42");
uriVariables.Add("hotel", "1");
result = template.Expand(uriVariables);
Assert.AreEqual(new Uri("http://example.com/hotels/1/bookings/42"), result, "Invalid expanded template");
}
示例8: ExpandWithAtSign
public void ExpandWithAtSign()
{
UriTemplate template = new UriTemplate("http://localhost/query={query}");
Uri uri = template.Expand("[email protected]");
Assert.AreEqual("http://localhost/[email protected]", uri.ToString());
}
示例9: ExpandVarArgsInvalidAmountVariables
public void ExpandVarArgsInvalidAmountVariables()
{
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
template.Expand("1", "42", 100);
}