csharp UrlBuilder

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp UrlBuilder相关的知识,希望对你有一定的参考价值。

using Microsoft.AspNetCore.Routing.Template;
using Microsoft.AspNetCore.Routing;
using System.Text.Encodings.Web;
using Microsoft.Extensions.ObjectPool;
using Microsoft.AspNetCore.Routing.Internal;
namespace chat
{
    public class UrlBuilder
    {
        public static string BuildUri(string routeTemplate, RouteValueDictionary values  ){
            var template = TemplateParser.Parse(routeTemplate);
            var urlencoder = UrlEncoder.Create(new TextEncoderSettings{});
            var poolpolicy = new UriBuilderContextPooledObjectPolicy();
            var pool = new DefaultObjectPool<UriBuildingContext>(poolpolicy);
            var binder = new TemplateBinder(urlEncoder: urlencoder, pool: pool, template: template, defaults: null);
            var x = binder.BindValues(values);
            return x;
        }
    }
}

以上是关于csharp UrlBuilder的主要内容,如果未能解决你的问题,请参考以下文章

URLBuilder简单快速构建URL链接

URLBuilder简单快速构建URL链接

绑定和返回函数中的“this”上下文中的打字稿错误

csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertWithCustomInputDataHandler.cs

csharp 例如-CSHARP-GroupDocs.Conversion.Examples.CSharp - 程序 - ConvertFilesToDifferentFormats.cs

csharp 例如-CSHARP-GroupDocs.Conversion.Examples.CSharp渲染,RenderPSDImageAsPath.cs