• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# System.UriTemplate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.UriTemplate的典型用法代码示例。如果您正苦于以下问题:C# UriTemplate类的具体用法?C# UriTemplate怎么用?C# UriTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UriTemplate类属于System命名空间,在下文中一共展示了UriTemplate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: BuildUriString

 public string BuildUriString(NancyContext context, string routeName, dynamic parameters)
 {
     var baseUri = new Uri(context.Request.BaseUri().TrimEnd('/'));
       var pathTemplate = AllRoutes.Single(r => r.Name == routeName).Path;
       var uriTemplate = new UriTemplate(pathTemplate, true);
       return uriTemplate.BindByName(baseUri, ToDictionary(parameters ?? new {})).ToString();
 }
开发者ID:horsdal,项目名称:Restbucks-on-Nancy,代码行数:7,代码来源:ResourceLinker.cs


示例2: TryUriTemplateMatch

 private bool TryUriTemplateMatch(string uri, out UriTemplateMatch uriTemplateMatch)
 {
     var uriTemplate = new UriTemplate(uri);
     var serverPath = Request.Url.GetServerBaseUri();
     uriTemplateMatch = uriTemplate.Match(new Uri(serverPath), Request.Url);
     return uriTemplateMatch != null;
 }
开发者ID:JamesTryand,项目名称:minimods,代码行数:7,代码来源:HttpContext.cs


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


示例4: when_validating_a_uri_template_with_url_encoded_chars

 public void when_validating_a_uri_template_with_url_encoded_chars()
 {
     var template = new UriTemplate("/streams/$all?embed={embed}");
     var uri = new Uri("http://127.0.0.1/streams/$all");
     var baseaddress = new Uri("http://127.0.0.1");
     Assert.IsTrue(template.Match(baseaddress, uri) != null);
 }        
开发者ID:thinkbeforecoding,项目名称:EventStore,代码行数:7,代码来源:mono_filestream_bug.cs


示例5: CreateFromUriTemplate

        public static UriTemplatePathSegment CreateFromUriTemplate(string segment, UriTemplate template)
        {
            // Identifying the type of segment - Literal|Compound|Variable
            switch (UriTemplateHelpers.IdentifyPartType(segment))
            {
                case UriTemplatePartType.Literal:
                    return UriTemplateLiteralPathSegment.CreateFromUriTemplate(segment, template);

                case UriTemplatePartType.Compound:
                    return UriTemplateCompoundPathSegment.CreateFromUriTemplate(segment, template);

                case UriTemplatePartType.Variable:
                    if (segment.EndsWith("/", StringComparison.Ordinal))
                    {
                        string varName = template.AddPathVariable(UriTemplatePartType.Variable,
                            segment.Substring(1, segment.Length - 3));
                        return new UriTemplateVariablePathSegment(segment, true, varName);
                    }
                    else
                    {
                        string varName = template.AddPathVariable(UriTemplatePartType.Variable,
                            segment.Substring(1, segment.Length - 2));
                        return new UriTemplateVariablePathSegment(segment, false, varName);
                    }

                default:
                    Fx.Assert("Invalid value from IdentifyStringNature");
                    return null;
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:30,代码来源:UriTemplatePathSegment.cs


示例6: CreateFromUriTemplate

        public static UriTemplateQueryValue CreateFromUriTemplate(string value, UriTemplate template)
        {
            // Checking for empty value
            if (value == null)
            {
                return UriTemplateQueryValue.Empty;
            }
            // Identifying the type of value - Literal|Compound|Variable
            switch (UriTemplateHelpers.IdentifyPartType(value))
            {
                case UriTemplatePartType.Literal:
                    return UriTemplateLiteralQueryValue.CreateFromUriTemplate(value);

                case UriTemplatePartType.Compound:
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(
                        SR.UTQueryCannotHaveCompoundValue, template.originalTemplate)));

                case UriTemplatePartType.Variable:
                    return new UriTemplateVariableQueryValue(template.AddQueryVariable(value.Substring(1, value.Length - 2)));

                default:
                    Fx.Assert("Invalid value from IdentifyStringNature");
                    return null;
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:25,代码来源:UriTemplateQueryValue.cs


示例7: CompetitionResultAppelRequestHandler

 public CompetitionResultAppelRequestHandler(HttpRequest Request, HttpResponse Response, Uri Prefix, UriTemplate CompetitionResultsTemplate, UriTemplate ResultResourceTemplate, string AcceptHeader)
     : base(Request, Response, Prefix, AcceptHeader)
 {
     this.CompetitionResultsTemplate = CompetitionResultsTemplate;
     this.ResultResourceTemplate = ResultResourceTemplate;
     processRequest();
 }
开发者ID:TheHandsomeCoder,项目名称:SOFT512RestAPI,代码行数:7,代码来源:CompetitionResultAppelRequestHandler.cs


示例8: BindUri

        public static Uri BindUri(this ISession session, Uri url, object parameters = null)
        {
            Uri baseUri = new Uri(url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped));
              UriTemplate template = new UriTemplate(url.GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped));

              return BindTemplate(baseUri, template, parameters);
        }
开发者ID:prearrangedchaos,项目名称:Ramone,代码行数:7,代码来源:BindingExtensions.cs


示例9: MethodAndUriTemplateOperationSelector

        public MethodAndUriTemplateOperationSelector(ServiceEndpoint endpoint)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException("endpoint");
            }

            this.delegates =
                new Dictionary<string, UriTemplateOperationSelector>();

            var operations = endpoint.Contract.Operations.Select(od => new HttpOperationDescription(od));

            foreach (var methodGroup in operations.GroupBy(od => od.GetWebMethod()))
            {
                UriTemplateTable table = new UriTemplateTable(endpoint.ListenUri);
                foreach (var operation in methodGroup)
                {
                    UriTemplate template = new UriTemplate(operation.GetUriTemplateString());
                    table.KeyValuePairs.Add(
                        new KeyValuePair<UriTemplate, object>(template, operation.Name));

                }

                table.MakeReadOnly(false);
                UriTemplateOperationSelector templateSelector =
                    new UriTemplateOperationSelector(table);
                this.delegates.Add(methodGroup.Key, templateSelector);
            }
        }
开发者ID:AlexZeitler,项目名称:WcfHttpMvcFormsAuth,代码行数:29,代码来源:MethodAndUriTemplateOperationSelector.cs


示例10: HtmlFormRequestDispatchFormatter

        public HtmlFormRequestDispatchFormatter(OperationDescription operation, UriTemplate uriTemplate, QueryStringConverter converter, IDispatchMessageFormatter innerFormatter)
            : base(operation, uriTemplate, converter, innerFormatter)
        {
            // This formatter will only support deserializing form post data to a type if:
            //  (1) The type can be converted via the QueryStringConverter or...
            //  (2) The type meets the following requirements:
            //      (A) The type is decorated with the DataContractAttribute
            //      (B) Every public field or property that is decorated with the DataMemberAttribute is of a type that
            //          can be converted by the QueryStringConverter

            this.canConvertBodyType = this.QueryStringConverter.CanConvert(this.BodyParameterType);

            if (!this.canConvertBodyType)
            {
                if (this.BodyParameterType.GetCustomAttributes(typeof(DataContractAttribute), false).Length == 0)
                {
                    throw new NotSupportedException(
                        string.Format("Body parameter '{0}' from operation '{1}' is of type '{2}', which is not decorated with a DataContractAttribute.  " +
                                      "Only body parameter types decorated with the DataContractAttribute are supported.",
                        this.BodyParameterName,
                        operation.Name,
                        this.BodyParameterType));
                }

                // For the body type, we'll need to cache information about each of the public fields/properties
                //  that is decorated with the DataMemberAttribute; we'll store this info in the bodyMembers dictionary
                //  where the member name is the dictionary key
                bodyMembers = new Dictionary<string, BodyMemberData>();

                GetBobyMemberDataForFields(operation.Name);
                GetBodyMemberDataForProperties(operation.Name);

                requiredBodyMembers = bodyMembers.Where(p => p.Value.IsRequired == true).Select(p => p.Key).ToArray();
            }
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:35,代码来源:HtmlFormRequestDispatchFormatter.cs


示例11: TestCompoundFragmentExpansionAssociativeMapVariable

        public void TestCompoundFragmentExpansionAssociativeMapVariable()
        {
            string template = "{#keys*}";
            UriTemplate uriTemplate = new UriTemplate(template);
            Uri uri = uriTemplate.BindByName(variables);
            string[] allowed =
                {
                    "#comma=,,dot=.,semi=;",
                    "#comma=,,semi=;,dot=.",
                    "#dot=.,comma=,,semi=;",
                    "#dot=.,semi=;,comma=,",
                    "#semi=;,comma=,,dot=.",
                    "#semi=;,dot=.,comma=,"
                };

            CollectionAssert.Contains(allowed, uri.ToString());

            UriTemplateMatch match = uriTemplate.Match(uri, new[] { "list" }, new[] { "keys" });
            Assert.IsNotNull(match);
            CollectionAssert.AreEqual((ICollection)variables["keys"], (ICollection)match.Bindings["keys"].Value);

            match = uriTemplate.Match(uri, requiredVariables, new[] { "list" }, new[] { "keys" });
            Assert.IsNotNull(match);
            CollectionAssert.AreEqual((ICollection)variables["keys"], (ICollection)match.Bindings["keys"].Value);
        }
开发者ID:gitter-badger,项目名称:dotnet-uritemplate,代码行数:25,代码来源:Level4Tests.cs


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


示例13: BuildUriString

        public string BuildUriString(string prefix, string template, dynamic parameters)
        {
            var newBaseUri = new Uri(baseUri.TrimEnd('/') + prefix);
              var uriTemplate = new UriTemplate(template, true);

              return uriTemplate.BindByName(newBaseUri, ToDictionary(parameters ?? new {})).ToString();
        }
开发者ID:saberone,项目名称:RestBench,代码行数:7,代码来源:ResourceLinker.cs


示例14: UriConfiguration

 public UriConfiguration(Uri baseAddress, UriTemplate recentFeedTemplate, UriTemplate feedTemplate, UriTemplate entryTemplate)
 {
     this.baseAddress = baseAddress;
     this.recentFeedTemplate = recentFeedTemplate;
     this.feedTemplate = feedTemplate;
     this.entryTemplate = entryTemplate;
 }
开发者ID:JunctionBoxca,项目名称:Rest-In-Practise-Product-Catalog-Service,代码行数:7,代码来源:UriConfiguration.cs


示例15: EncryptionButtonInValidateCard_Click

        protected void EncryptionButtonInValidateCard_Click(object sender, EventArgs e)
        {
            Uri baseUri = new Uri("http://webstrar49.fulton.asu.edu/page3/Service1.svc");
            UriTemplate myTemplate = new UriTemplate("encrypt?plainText={plainText}");

            String plainText = PlainText_TextBox1.Text;
            Uri completeUri = myTemplate.BindByPosition(baseUri, plainText);

            System.Net.WebClient webClient = new System.Net.WebClient();
            byte[] content = webClient.DownloadData(completeUri);

            //EncryptionService.Service1Client encryptionClient = new EncryptionService.Service1Client();
            // String cipher=encryptionClient.encrypt(plainText);

            String contentinString = Encoding.UTF8.GetString(content, 0, content.Length);

            String pattern = @"(?<=\>)(.*?)(?=\<)";
            Regex r = new Regex(pattern);
            Match m = r.Match(contentinString);

            String cipher = "";
            if (m.Success)
            {
                cipher = m.Groups[1].ToString();
            }

            cipherTextBox.Enabled = true;
            cipherTextBox.Text = cipher;
            cipherTextBox.Enabled = false;
        }
开发者ID:jvutukur,项目名称:DistributedSoftwareDevelopmentProject,代码行数:30,代码来源:Payment.aspx.cs


示例16: SerializedResult

 public SerializedResult(Result x, Uri Prefix, UriTemplate ResultResourceTemplate, UriTemplate FencerResourceTemplate,UriTemplate CompetitionResourceTemplate)
 {
     ID = x.ResultID;
     Placing = x.Placing;
     ReferenceURI = ResultResourceTemplate.BindByPosition(Prefix, ID.ToString());
     FencerURI = FencerResourceTemplate.BindByPosition(Prefix, x.FencerID.ToString());
     CompetitionURI = CompetitionResourceTemplate.BindByPosition(Prefix, x.CompetitionID.ToString());
 }
开发者ID:TheHandsomeCoder,项目名称:SOFT512RestAPI,代码行数:8,代码来源:SerializedResult.cs


示例17: WhenMatchingMultipleArgs_ThenUriTemplateMatches

	public void WhenMatchingMultipleArgs_ThenUriTemplateMatches()
	{
		var template = new UriTemplate("?search={search}");

		var match = template.Match(new Uri("http://localhost/products"), new Uri("http://localhost/products?search=foo,bar"));

		Assert.NotNull(match);
	}
开发者ID:netfx,项目名称:extensions,代码行数:8,代码来源:HttpQueryableServiceSpec.cs


示例18: AddHandler

 public void AddHandler(UriTemplate uriTemplate, HandlerDelegate handler)
 {
     _uriHandlers.Add(new UriHandler()
     {
         UriTemplate = uriTemplate,
         Handler = handler
     });
 }
开发者ID:veblush,项目名称:aardwolf,代码行数:8,代码来源:HandlerDispatcher.cs


示例19: SerializedCompetition

 public SerializedCompetition(Competition x, Uri Prefix, UriTemplate CompetitionTemplate, UriTemplate CompetitionResultTemplate)
 {
     ID = x.CompetitionID;
     Title = x.Title;
     Venue = x.Venue;
     ReferenceURI = CompetitionTemplate.BindByPosition(Prefix, ID.ToString());
     CompetitionResultsURI = CompetitionResultTemplate.BindByPosition(Prefix, ID.ToString());
 }
开发者ID:TheHandsomeCoder,项目名称:SOFT512RestAPI,代码行数:8,代码来源:SerializedCompetition.cs


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# System.UriTemplateMatch类代码示例发布时间:2022-05-26
下一篇:
C# System.UriParser类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap