Table of Contents

TryDetectXmlEncoding Method

Definition

Namespace
Cuemon.Xml
Assemblies
Cuemon.Xml.dll
Source
src/Cuemon.Xml/Extensions/StreamDecoratorExtensions.cs

TryDetectXmlEncoding(IDecorator<Stream>, out Encoding)

Tries to resolve the Encoding level of the XML document from the enclosed Stream of the specified decorator.

public static bool TryDetectXmlEncoding(this IDecorator<Stream> decorator, out Encoding result)

Parameters

decorator IDecorator<Stream>

The IDecorator<T> to extend.

result Encoding

When this method returns, it contains the Encoding value equivalent to the encoding level of the XML document contained in the enclosed Stream of the specified decorator, if the conversion succeeded, or a null reference if the conversion failed. The conversion fails if the enclosed Stream of the specified decorator is null, does not contain BOM information or does not contain an XmlDeclaration.

Returns

bool

true if the enclosed Stream of the specified decorator was converted successfully; otherwise, false.

Exceptions

ArgumentNullException

decorator cannot be null.