Class XmlWriterExtensions
- Namespace
- Cuemon.Extensions.Xml
- Assembly
- Cuemon.Extensions.Xml.dll
Extension methods for the XmlWriter class.
public static class XmlWriterExtensions
- Inheritance
-
XmlWriterExtensions
Methods
WriteEncapsulatingElementWhenNotNull<T>(XmlWriter, T, XmlQualifiedEntity, Action<XmlWriter, T>)
Writes the specified value with the delegate nodeWriter.
If elementName is not null, then the delegate nodeWriter is called from within an encapsulating Start- and End-element.
public static void WriteEncapsulatingElementWhenNotNull<T>(this XmlWriter writer, T value, XmlQualifiedEntity elementName, Action<XmlWriter, T> nodeWriter)
Parameters
writerXmlWriterThe XmlWriter to extend.
valueTThe object to serialize.
elementNameXmlQualifiedEntityThe optional fully qualified name of the element.
nodeWriterAction<XmlWriter, T>The delegate node writer.
Type Parameters
TThe type of the object to serialize.
Exceptions
- ArgumentNullException
writercannot be null.
WriteObject(XmlWriter, object, Type, Action<XmlFormatterOptions>)
Serializes the specified value into an XML format.
public static void WriteObject(this XmlWriter writer, object value, Type objectType, Action<XmlFormatterOptions> setup = null)
Parameters
writerXmlWriterThe XmlWriter to extend.
valueobjectThe object to serialize.
objectTypeTypeThe type of the object to serialize.
setupAction<XmlFormatterOptions>The XmlFormatterOptions which may be configured.
Exceptions
- ArgumentNullException
writercannot be null.
WriteObject<T>(XmlWriter, T, Action<XmlFormatterOptions>)
Serializes the specified value into an XML format.
public static void WriteObject<T>(this XmlWriter writer, T value, Action<XmlFormatterOptions> setup = null)
Parameters
writerXmlWriterThe XmlWriter to extend.
valueTThe object to serialize.
setupAction<XmlFormatterOptions>The XmlFormatterOptions which may be configured.
Type Parameters
TThe type of the object to serialize.
Exceptions
- ArgumentNullException
writercannot be null.
WriteStartElement(XmlWriter, XmlQualifiedEntity)
Writes the specified start tag and associates it with the given elementName.
public static void WriteStartElement(this XmlWriter writer, XmlQualifiedEntity elementName)
Parameters
writerXmlWriterThe XmlWriter to extend.
elementNameXmlQualifiedEntityThe fully qualified name of the element.
Exceptions
- ArgumentNullException
writercannot be null.
WriteXmlRootElement<T>(XmlWriter, T, Action<XmlWriter, T, XmlQualifiedEntity>, XmlQualifiedEntity)
Writes the XML root element to an existing writer.
public static void WriteXmlRootElement<T>(this XmlWriter writer, T value, Action<XmlWriter, T, XmlQualifiedEntity> treeWriter, XmlQualifiedEntity rootEntity = null)
Parameters
writerXmlWriterThe XmlWriter to extend.
valueTThe object to serialize.
treeWriterAction<XmlWriter, T, XmlQualifiedEntity>The delegate used to write the XML hierarchy.
rootEntityXmlQualifiedEntityThe optional XmlQualifiedEntity that will provide the name of the root element.
Type Parameters
TThe type of the object to serialize.
Exceptions
- ArgumentNullException
writercannot be null.