Class StreamDecoratorExtensions
- Namespace
- Cuemon.Xml
- Assembly
- Cuemon.Xml.dll
Extension methods for the System.IO.Stream class hidden behind the IDecorator<T> interface.
public static class StreamDecoratorExtensions
- Inheritance
-
ObjectStreamDecoratorExtensions
Methods
ToXmlReader(IDecorator<Stream>, Encoding, Action<XmlReaderSettings>)
Converts the enclosed System.IO.Stream of the specified decorator
to an System.Xml.XmlReader.
public static XmlReader ToXmlReader(this IDecorator<Stream> decorator, Encoding encoding = null, Action<XmlReaderSettings> setup = null)
Parameters
decorator
IDecorator<Stream>The IDecorator<T> to extend.
encoding
EncodingThe text encoding to use.
setup
Action<XmlReaderSettings>The System.Xml.XmlReaderSettings which may be configured.
Returns
- XmlReader
An System.Xml.XmlReader representation of the enclosed System.IO.Stream of the specified
decorator
.
Remarks
If encoding
is null, an System.Text.Encoding object will be attempted resolved by TryDetectXmlEncoding(IDecorator<Stream>, out Encoding).
Exceptions
- System.ArgumentNullException
decorator
cannot be null.
TryDetectXmlEncoding(IDecorator<Stream>, out Encoding)
Tries to resolve the System.Text.Encoding level of the XML document from the enclosed System.IO.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
EncodingWhen this method returns, it contains the System.Text.Encoding value equivalent to the encoding level of the XML document contained in the enclosed System.IO.Stream of the specified
decorator
, if the conversion succeeded, or a null reference if the conversion failed. The conversion fails if the enclosed System.IO.Stream of the specifieddecorator
is null, does not contain BOM information or does not contain an System.Xml.XmlDeclaration.
Returns
- Boolean
true
if the enclosed System.IO.Stream of the specifieddecorator
was converted successfully; otherwise,false
.
Exceptions
- System.ArgumentNullException
decorator
cannot be null.