本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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())))
{
}