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


C# UriTemplates.UriTemplate類代碼示例

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


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

示例1: 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);
        }
開發者ID:ritterim,項目名稱:Supurlative,代碼行數:14,代碼來源:TemplateUrlTests.cs

示例2: 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);
        }
開發者ID:ritterim,項目名稱:Supurlative,代碼行數:16,代碼來源:TemplateUrlTests.cs

示例3: 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);
        }
開發者ID:ritterim,項目名稱:Supurlative,代碼行數:17,代碼來源:TemplateUrlTests.cs

示例4: BuildInstance

        public ResourceOptions BuildInstance()
        {
            var metadata = _metadataProvider.BuildInstance();
            var resources = metadata.Resources;
            var supportedParameters = new Dictionary<string, object>{ {"hash", metadata.Hash} };

            var browserAgentScriptTemplate = new UriTemplate(resources.GetValueOrDefault("agent", string.Empty), true);
            var httpMessageTemplate = new UriTemplate(resources.GetValueOrDefault("message-ingress", string.Empty), true);
            var hudScriptTemplate = new UriTemplate(resources.GetValueOrDefault("hud", string.Empty), true);
            var contextTemplate = new UriTemplate(resources.GetValueOrDefault("context", string.Empty), true);
            var metadataTemplate = new UriTemplate(resources.GetValueOrDefault("metadata", string.Empty), true);
            var clientScriptTemplate = new UriTemplate(resources.GetValueOrDefault("client", string.Empty), true);

            return new ResourceOptions
            {
                BrowserAgentScriptTemplate = browserAgentScriptTemplate.ResolveWith(supportedParameters),
                MessageIngressTemplate = httpMessageTemplate.ResolveWith(supportedParameters),
                HudScriptTemplate = hudScriptTemplate.ResolveWith(supportedParameters),
                ContextTemplate = contextTemplate.ResolveWith(supportedParameters),
                MetadataTemplate = metadataTemplate.ResolveWith(supportedParameters),
                ClientScriptTemplate = clientScriptTemplate.ResolveWith(supportedParameters)
            };
        }
開發者ID:mike-kaufman,項目名稱:Glimpse.Prototype,代碼行數:23,代碼來源:DefaultResourceOptionsProvider.cs


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