當前位置: 首頁>>代碼示例>>C#>>正文


C# UriTemplate.Resolve方法代碼示例

本文整理匯總了C#中Tavis.UriTemplates.UriTemplate.Resolve方法的典型用法代碼示例。如果您正苦於以下問題:C# UriTemplate.Resolve方法的具體用法?C# UriTemplate.Resolve怎麽用?C# UriTemplate.Resolve使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tavis.UriTemplates.UriTemplate的用法示例。


在下文中一共展示了UriTemplate.Resolve方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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:panesofglass,項目名稱:UriTemplates,代碼行數:8,代碼來源:UsageTests.cs

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: ShouldResolveMatrixParameter

        public void ShouldResolveMatrixParameter()
        {
            var template = new UriTemplate("http://example.org/foo{;lat,lng}");

            double lat = 31.464, lng = 74.386;

            template.SetParameter("lat", lat);
            template.SetParameter("lng", lng);

            var uriString = template.Resolve();
            Assert.Equal("http://example.org/foo;lat=31.464;lng=74.386", uriString);
        }
開發者ID:tavis-software,項目名稱:Tavis.UriTemplates,代碼行數:12,代碼來源:UsageTests.cs

示例14: PreserveReservedCharacterExpansion

        public void PreserveReservedCharacterExpansion()
        {
            UriTemplate template = new UriTemplate("https://foo.com/?format={+format}");
            template.SetParameter("format", "application/vnd.foo+xml");

            var result = template.Resolve();

            Assert.Equal("https://foo.com/?format=application/vnd.foo+xml", result);

            var httpClient = new HttpClient();

            var response = httpClient.GetAsync("http://yahoo.com/foo%2Fbar").Result;
        }
開發者ID:rollingthunder,項目名稱:UriTemplates,代碼行數:13,代碼來源:UsageTests.cs

示例15: ShouldResolveUriTemplateWithNonStringParameter

        public void ShouldResolveUriTemplateWithNonStringParameter()
        {
            var template = new UriTemplate("http://example.org/foo/{bar}/baz{?lat,lng}");

            double lat = 31.464, lng = 74.386;

            template.SetParameter("bar", "yo");
            template.SetParameter("lat", lat);
            template.SetParameter("lng", lng);
            
            var uriString = template.Resolve();
            Assert.Equal("http://example.org/foo/yo/baz?lat=31.464&lng=74.386", uriString);
        }
開發者ID:khalidabuhakmeh,項目名稱:Tavis.UriTemplates,代碼行數:13,代碼來源:UsageTests.cs


注:本文中的Tavis.UriTemplates.UriTemplate.Resolve方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。