本文整理匯總了C#中Tavis.UriTemplates.UriTemplate.AddParameter方法的典型用法代碼示例。如果您正苦於以下問題:C# UriTemplate.AddParameter方法的具體用法?C# UriTemplate.AddParameter怎麽用?C# UriTemplate.AddParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tavis.UriTemplates.UriTemplate
的用法示例。
在下文中一共展示了UriTemplate.AddParameter方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Can_generate_a_path_with_anonymous_complex_route_properties
public void Can_generate_a_path_with_anonymous_complex_route_properties()
{
string expected = _baseUrl + "foo/1?bar.abc=abc&bar.def=def";
const string routeName = "foo.show";
const string routeTemplate = "foo/{id}";
string template = TestHelper.CreateATemplateGenerator(_baseUrl, routeName, routeTemplate)
.Generate(routeName, new { Id = 1, Bar = new { Abc = "abc", Def = "def" } });
var uriTemplate = new UriTemplate(template);
uriTemplate.AddParameters(new { id = 1 });
uriTemplate.AddParameter("bar.abc", "abc");
uriTemplate.AddParameter("bar.def", "def");
string actual = uriTemplate.Resolve();
Assert.Equal(expected, actual);
}
示例2: Can_generate_a_fully_qualified_path
public void Can_generate_a_fully_qualified_path()
{
string expected = _baseUrl + "foo/1";
const string routeName = "foo.show";
const string routeTemplate = "foo/{id}";
string template = TestHelper.CreateATemplateGenerator(_baseUrl, routeName, routeTemplate)
.Generate(routeName);
var uriTemplate = new UriTemplate(template);
uriTemplate.AddParameter("id", 1);
string actual = uriTemplate.Resolve();
Assert.Equal(expected, actual);
}
示例3: Can_generate_two_optional_path_items_template
public void Can_generate_two_optional_path_items_template()
{
string expected = _baseUrl + "foo/2";
const string routeName = "foo.one.two";
const string routeTemplate = "foo/{one}/{two}";
string template = TestHelper.CreateATemplateGenerator(_baseUrl, routeName, routeTemplate,
routeDefaults: new { one = RouteParameter.Optional, two = RouteParameter.Optional })
.Generate(routeName, new { two = 2 });
var uriTemplate = new UriTemplate(template);
uriTemplate.AddParameter("two", "2");
string actual = uriTemplate.Resolve();
Assert.Equal(expected, actual);
}