Class StreamDecoratorExtensions
Extension methods for the Stream class hidden behind the IDecorator<T> interface.
public static class StreamDecoratorExtensions
- Inheritance
-
StreamDecoratorExtensions
Methods
ToXmlReader(IDecorator<Stream>, Encoding, Action<XmlReaderSettings>)
public static XmlReader ToXmlReader(this IDecorator<Stream> decorator, Encoding encoding = null, Action<XmlReaderSettings> setup = null)
Parameters
decoratorIDecorator<Stream>The IDecorator<T> to extend.
encodingEncodingThe text encoding to use.
setupAction<XmlReaderSettings>The XmlReaderSettings which may be configured.
Returns
Remarks
If encoding is null, an Encoding object will be attempted resolved by TryDetectXmlEncoding(IDecorator<Stream>, out Encoding).
Exceptions
- ArgumentNullException
decoratorcannot be null.
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
decoratorIDecorator<Stream>The IDecorator<T> to extend.
resultEncodingWhen 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 specifieddecoratoris null, does not contain BOM information or does not contain an XmlDeclaration.
Returns
- bool
trueif the enclosed Stream of the specifieddecoratorwas converted successfully; otherwise,false.
Exceptions
- ArgumentNullException
decoratorcannot be null.