当前位置: 首页>>代码示例>>C#>>正文


C# UriTemplate.Expand方法代码示例

本文整理汇总了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");
 }
开发者ID:nsavga,项目名称:spring-net-rest,代码行数:7,代码来源:UriTemplateTests.cs

示例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");
 }
开发者ID:nsavga,项目名称:spring-net-rest,代码行数:7,代码来源:UriTemplateTests.cs

示例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);
        }
开发者ID:gabrielgreen,项目名称:spring-net-rest,代码行数:8,代码来源:UriTemplateTests.cs

示例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");
        }
开发者ID:nsavga,项目名称:spring-net-rest,代码行数:12,代码来源:UriTemplateTests.cs

示例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");
        }
开发者ID:gabrielgreen,项目名称:spring-net-rest,代码行数:16,代码来源:UriTemplateTests.cs

示例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");
 }
开发者ID:gabrielgreen,项目名称:spring-net-rest,代码行数:6,代码来源:UriTemplateTests.cs

示例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");
        }
开发者ID:gabrielgreen,项目名称:spring-net-rest,代码行数:16,代码来源:UriTemplateTests.cs

示例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());
 }
开发者ID:gabrielgreen,项目名称:spring-net-rest,代码行数:6,代码来源:UriTemplateTests.cs

示例9: ExpandVarArgsInvalidAmountVariables

 public void ExpandVarArgsInvalidAmountVariables()
 {
     UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
     template.Expand("1", "42", 100);
 }
开发者ID:gabrielgreen,项目名称:spring-net-rest,代码行数:5,代码来源:UriTemplateTests.cs


注:本文中的System.UriTemplate.Expand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。