Class StreamExtensions
- Namespace
- Cuemon.Extensions.Xml
- Assembly
- Cuemon.Extensions.Xml.dll
Extension methods for the Stream class.
public static class StreamExtensions
- Inheritance
-
StreamExtensions
Methods
CopyXmlStream(Stream, Action<XmlWriterSettings>)
Copies the entire XML Stream following the output format of setup.
public static Stream CopyXmlStream(this Stream value, Action<XmlWriterSettings> setup = null)
Parameters
valueStreamThe XML Stream to extend.
setupAction<XmlWriterSettings>The XmlWriterSettings which may be configured.
Returns
Exceptions
- ArgumentNullException
valuecannot be null.
RemoveXmlNamespaceDeclarations(Stream, Action<XmlWriterSettings>)
Remove the XML namespace declarations from the specified value.
public static Stream RemoveXmlNamespaceDeclarations(this Stream value, Action<XmlWriterSettings> setup = null)
Parameters
valueStreamThe XML Stream to extend.
setupAction<XmlWriterSettings>The XmlWriterSettings which may be configured.
Returns
ToXmlReader(Stream, Encoding, Action<XmlReaderSettings>)
Converts the given value to an XmlReader.
public static XmlReader ToXmlReader(this Stream value, Encoding encoding = null, Action<XmlReaderSettings> setup = null)
Parameters
valueStreamThe XML Stream 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(Stream, out Encoding).
Exceptions
- ArgumentNullException
valuecannot be null.
TryDetectXmlEncoding(Stream, out Encoding)
public static bool TryDetectXmlEncoding(this Stream value, out Encoding result)
Parameters
valueStreamThe XML Stream to extend.
resultEncodingWhen this method returns, it contains the Encoding value equivalent to the encoding level of the XML document contained in
value, if the conversion succeeded, or a null reference (Nothing in Visual Basic) if the conversion failed. The conversion fails if thevalueparameter is null, does not contain BOM information or does not contain an XmlDeclaration.
Returns
- bool
trueif thevalueparameter was converted successfully; otherwise,false.
Exceptions
- ArgumentNullException
valuecannot be null.