當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。