本文整理汇总了C#中UriTemplate类的典型用法代码示例。如果您正苦于以下问题:C# UriTemplate类的具体用法?C# UriTemplate怎么用?C# UriTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UriTemplate类属于命名空间,在下文中一共展示了UriTemplate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: LabelExpansionWithDotPrefixAndEmptyKeys
public void LabelExpansionWithDotPrefixAndEmptyKeys()
{
var template = new UriTemplate("X{.empty_keys}");
template.SetParameter("empty_keys", new Dictionary<string, string>());
var uriString = template.Resolve();
Assert.Equal("X", uriString);
}
开发者ID:panesofglass,项目名称:UriTemplates,代码行数:7,代码来源:UsageTests.cs
示例2: ExtendedSamplesTest
public void ExtendedSamplesTest(string template, string[] results, TestSet.TestCase testCase)
{
var uriTemplate = new UriTemplate(template);
foreach (var variable in testCase.TestSet.Variables)
{
uriTemplate.SetParameter(variable.Key, variable.Value);
}
string result = null;
ArgumentException aex = null;
try
{
result = uriTemplate.Resolve();
}
catch (ArgumentException ex)
{
aex = ex;
}
if (results[0] == "False")
{
Assert.NotNull(aex);
}
else
{
Assert.True(results.Contains(result));
}
}
开发者ID:khalidabuhakmeh,项目名称:Tavis.UriTemplates,代码行数:32,代码来源:SpecTests.cs
示例3: FailureSamplesTest
// Disabled for the moment. [Theory, PropertyData("FailureSamples")]
public void FailureSamplesTest(string template, string[] results, TestSet.TestCase testCase)
{
var uriTemplate = new UriTemplate(template);
foreach (var variable in testCase.TestSet.Variables)
{
uriTemplate.SetParameter(variable.Key, variable.Value);
}
string result = null;
ArgumentException aex = null;
try
{
result = uriTemplate.Resolve();
}
catch (ArgumentException ex)
{
aex = ex;
}
Assert.NotNull(aex);
}
开发者ID:khalidabuhakmeh,项目名称:Tavis.UriTemplates,代码行数:27,代码来源:SpecTests.cs
示例4: FactMethodName
public void FactMethodName()
{
UriTemplate template = new UriTemplate("https://api.github.com/search/code?q={query}{&page,per_page,sort,order}");
template.SetParameter("query", "1234");
template.SetParameter("per_page", "19");
var result = template.Resolve();
}
开发者ID:rollingthunder,项目名称:UriTemplates,代码行数:7,代码来源:UsageTests.cs
示例5: ShouldAllowUriTemplateWithPathSegmentParameter
public void ShouldAllowUriTemplateWithPathSegmentParameter()
{
var template = new UriTemplate("http://example.org/foo/{bar}/baz");
template.SetParameter("bar", "yo");
var uriString = template.Resolve();
Assert.Equal("http://example.org/foo/yo/baz", uriString);
}
开发者ID:khalidabuhakmeh,项目名称:Tavis.UriTemplates,代码行数:7,代码来源:UsageTests.cs
示例6: QueryParametersTheNewWay
public void QueryParametersTheNewWay()
{
var url = new UriTemplate("http://example.org/customers{?active}")
.AddParameter("active", "true")
.Resolve();
Assert.Equal("http://example.org/customers?active=true", url);
}
开发者ID:JMontagu,项目名称:Tavis.UriTemplates,代码行数:8,代码来源:UriTemplateExtensionsTests.cs
示例7: UpdatePathParameter
public void UpdatePathParameter()
{
var url = new UriTemplate("http://example.org/{tenant}/customers")
.AddParameter("tenant", "acmé")
.Resolve();
Assert.Equal("http://example.org/acm%C3%A9/customers", url);
}
开发者ID:JMontagu,项目名称:Tavis.UriTemplates,代码行数:8,代码来源:UriTemplateExtensionsTests.cs
示例8: ShouldResolveUriTemplateWithNonStringParameter
public void ShouldResolveUriTemplateWithNonStringParameter()
{
var url = new UriTemplate("http://example.org/location{?lat,lng}")
.AddParameters(new { lat = 31.464, lng = 74.386 })
.Resolve();
Assert.Equal("http://example.org/location?lat=31.464&lng=74.386", url);
}
开发者ID:JMontagu,项目名称:Tavis.UriTemplates,代码行数:8,代码来源:UriTemplateExtensionsTests.cs
示例9: SpecTest
public void SpecTest(TestCase testCase)
{
Assume.That(!testCase.IsInvalid);
var uriTemplate = new UriTemplate(testCase.Template);
var uri = uriTemplate.Resolve(testCase.Suite.Variables);
Assert.Contains(uri, testCase.Expecteds);
}
开发者ID:pombredanne,项目名称:uri-templates-1,代码行数:8,代码来源:SpecBaseTests.cs
示例10: ResolveDocumentationUri
private static Uri ResolveDocumentationUri(ILinkObject link, string rel)
{
var template = new UriTemplate(link.Href.ToString());
template.SetParameter("rel", rel);
return new Uri(template.Resolve());
}
开发者ID:JMontagu,项目名称:HalClient.Net,代码行数:8,代码来源:RootResourceObject.cs
示例11: ShouldAllowUriTemplateWithQueryParamsButNoValues
public void ShouldAllowUriTemplateWithQueryParamsButNoValues()
{
var template = new UriTemplate("http://example.org/foo{?bar,baz}");
//template.SetParameter("bar", "yo");
//template.SetParameter("blar", "yuck");
var uriString = template.Resolve();
Assert.Equal("http://example.org/foo", uriString);
}
开发者ID:khalidabuhakmeh,项目名称:Tavis.UriTemplates,代码行数:8,代码来源:UsageTests.cs
示例12: ShouldAllowUriTemplateWithQueryParamsWithOneValue
public void ShouldAllowUriTemplateWithQueryParamsWithOneValue()
{
var template = new UriTemplate("http://example.org/foo{?bar,baz}");
template.SetParameter("baz", "yo");
var uriString = template.Resolve();
Assert.Equal("http://example.org/foo?baz=yo", uriString);
}
开发者ID:khalidabuhakmeh,项目名称:Tavis.UriTemplates,代码行数:8,代码来源:UsageTests.cs
示例13: ResolveTemplateUrl
private static string ResolveTemplateUrl(string href, Dictionary<string, string> values)
{
var template = new UriTemplate(href);
foreach (var templateValue in values)
template.SetParameter(templateValue.Key, templateValue.Value);
return template.Resolve();
}
开发者ID:hyperfriendly,项目名称:Hyperfriendly.Client,代码行数:9,代码来源:QueryStringComposer.cs
示例14: UriTemplateBuilder
public UriTemplateBuilder(UriTemplate uriTemplate)
{
if (uriTemplate == null)
{
throw new ArgumentNullException("uriTemplate");
}
this.components = new List<IUriTemplateComponent>(uriTemplate.Components);
}
开发者ID:pombredanne,项目名称:uri-templates-1,代码行数:9,代码来源:UriTemplateBuilder.cs
示例15: ShouldAllowListAndSingleValueInQueryParam
public void ShouldAllowListAndSingleValueInQueryParam()
{
var template = new UriTemplate("http://example.org{/id*}{?fields,token}");
template.SetParameter("id", new List<string>() { "person", "albums" });
template.SetParameter("fields", new List<string>() { "id", "name", "picture" });
template.SetParameter("token", "12345");
var uriString = template.Resolve();
Assert.Equal("http://example.org/person/albums?fields=id,name,picture&token=12345", uriString);
}
开发者ID:panesofglass,项目名称:UriTemplates,代码行数:9,代码来源:UsageTests.cs
示例16: QueryParametersTheNewWayWithoutValue
public void QueryParametersTheNewWayWithoutValue()
{
var url = new UriTemplate("http://example.org/customers{?active}")
.AddParameters(null)
.Resolve();
Assert.Equal("http://example.org/customers", url);
}
开发者ID:JMontagu,项目名称:Tavis.UriTemplates,代码行数:9,代码来源:UriTemplateExtensionsTests.cs
示例17: ShouldAllowUriTemplateToRemoveParameter
public void ShouldAllowUriTemplateToRemoveParameter()
{
var template = new UriTemplate("http://example.org/foo{?bar,baz}");
template.SetParameter("bar", "yo");
template.SetParameter("baz", "yuck");
template.ClearParameter("bar");
var uriString = template.Resolve();
Assert.Equal("http://example.org/foo?baz=yuck", uriString);
}
开发者ID:khalidabuhakmeh,项目名称:Tavis.UriTemplates,代码行数:10,代码来源:UsageTests.cs
示例18: Query_param_with_list_array
public void Query_param_with_list_array()
{
UriTemplate template = new UriTemplate("/foo/{foo}/baz{?haz}");
template.SetParameter("foo", "1234");
template.SetParameter("haz", new string[] { "foo", "bar" });
string uri = template.Resolve();
Assert.Equal("/foo/1234/baz?haz=foo,bar", uri);
}
开发者ID:rollingthunder,项目名称:UriTemplates,代码行数:10,代码来源:UsageTests.cs
示例19: MakeTemplate
public static UriTemplate MakeTemplate(this Uri uri, IDictionary<string, object> parameters)
{
var target = uri.GetComponents(UriComponents.AbsoluteUri
& ~UriComponents.Query
& ~UriComponents.Fragment, UriFormat.Unescaped);
var template = new UriTemplate(target + "{?" + string.Join(",", parameters.Keys.ToArray()) + "}");
template.AddParameters(parameters);
return template;
}
开发者ID:JMontagu,项目名称:Tavis.UriTemplates,代码行数:10,代码来源:UriTemplateExtensions.cs
示例20: GetProfile
public async Task<ContentResponse> GetProfile(string artistId)
{
var parameters = new Dictionary<string, string>();
parameters.Add("apikey", _apikey);
parameters.Add("artistid", artistId);
var template = new UriTemplate("artist/profile?api_key={apikey}&id=songkick:artist:{artistid}&bucket=id:spotify&format=json");
return await GetWithRetryAsync(baseUri, template, parameters);
}
开发者ID:dupuyjs,项目名称:rimshot,代码行数:10,代码来源:EchonestClient.cs
注:本文中的UriTemplate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论