当前位置: 首页>>代码示例>>C#>>正文


C# IConfiguration.DefaultEncoding方法代码示例

本文整理汇总了C#中IConfiguration.DefaultEncoding方法的典型用法代码示例。如果您正苦于以下问题:C# IConfiguration.DefaultEncoding方法的具体用法?C# IConfiguration.DefaultEncoding怎么用?C# IConfiguration.DefaultEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IConfiguration的用法示例。


在下文中一共展示了IConfiguration.DefaultEncoding方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateDocumentOptions

        /// <summary>
        /// Creates new document creation options. Selects the source from the
        /// response by potentially using the encoding from the configuration.
        /// </summary>
        /// <param name="response">The response to hand over.</param>
        /// <param name="configuration">The configuration to use.</param>
        public CreateDocumentOptions(IResponse response, IConfiguration configuration)
        {
            var contentType = response.GetContentType(MimeTypeNames.Html);
            var encoding = configuration.DefaultEncoding();
            var charset = contentType.GetParameter(AttributeNames.Charset);

            if (!String.IsNullOrEmpty(charset) && TextEncoding.IsSupported(charset))
                encoding = TextEncoding.Resolve(charset);

            _source = new TextSource(response.Content, encoding);
            _contentType = contentType;
            _response = response;
        }
开发者ID:fjwuyongzhi,项目名称:AngleSharp,代码行数:19,代码来源:CreateDocumentOptions.cs

示例2: CreateDocumentOptions

        /// <summary>
        /// Creates a new set of document options from the given response with
        /// the provided configuration.
        /// </summary>
        /// <param name="response">The response to pass on.</param>
        /// <param name="configuration">The configuration to use.</param>
        /// <param name="ancestor">The optional import ancestor.</param>
        public CreateDocumentOptions(IResponse response, IConfiguration configuration, IDocument ancestor = null)
        {
            var contentType = response.GetContentType(MimeTypeNames.Html);
            var charset = contentType.GetParameter(AttributeNames.Charset);
            var source = new TextSource(response.Content, configuration.DefaultEncoding());

            if (!String.IsNullOrEmpty(charset) && TextEncoding.IsSupported(charset))
            {
                source.CurrentEncoding = TextEncoding.Resolve(charset);
            }

            _source = source;
            _contentType = contentType;
            _response = response;
            _ancestor = ancestor;
        }
开发者ID:Wojdav,项目名称:AngleSharp,代码行数:23,代码来源:CreateDocumentOptions.cs

示例3: CreateSourceFor

            internal TextSource CreateSourceFor(IConfiguration configuration)
            {
                if (source != null)
                    return source;
                else if (content != null)
                    return new TextSource(content, configuration.DefaultEncoding());

                return new TextSource(String.Empty);
            }
开发者ID:JackieyLi,项目名称:AngleSharp,代码行数:9,代码来源:BrowsingContextExtensions.cs

示例4: XmlDomBuilder

 /// <summary>
 /// Creates a new instance of the XML parser with an new document
 /// based on the given stream.
 /// </summary>
 /// <param name="stream">The stream to use as source.</param>
 /// <param name="configuration">
 /// [Optional] The configuration to use.
 /// </param>
 public XmlDomBuilder(Stream stream, IConfiguration configuration = null)
     : this(new XmlDocument(BrowsingContext.New(configuration), new TextSource(stream, configuration.DefaultEncoding())))
 {
 }
开发者ID:workwebresources,项目名称:AngleSharp,代码行数:12,代码来源:XmlDomBuilder.cs


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