Table of Contents

Class XmlWriterExtensions

Namespace
Cuemon.Extensions.Xml
Assembly
Cuemon.Extensions.Xml.dll

Extension methods for the System.Xml.XmlWriter class.

public static class XmlWriterExtensions
Inheritance
Object
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

writer XmlWriter

The System.Xml.XmlWriter to extend.

value T

The object to serialize.

elementName XmlQualifiedEntity

The optional fully qualified name of the element.

nodeWriter Action<XmlWriter, T>

The delegate node writer.

Type Parameters

T

The type of the object to serialize.

Exceptions

System.ArgumentNullException

writer cannot 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

writer XmlWriter

The System.Xml.XmlWriter to extend.

value Object

The object to serialize.

objectType Type

The type of the object to serialize.

setup Action<XmlFormatterOptions>

The XmlFormatterOptions which may be configured.

Exceptions

System.ArgumentNullException

writer cannot 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

writer XmlWriter

The System.Xml.XmlWriter to extend.

value T

The object to serialize.

setup Action<XmlFormatterOptions>

The XmlFormatterOptions which may be configured.

Type Parameters

T

The type of the object to serialize.

Exceptions

System.ArgumentNullException

writer cannot 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

writer XmlWriter

The System.Xml.XmlWriter to extend.

elementName XmlQualifiedEntity

The fully qualified name of the element.

Exceptions

System.ArgumentNullException

writer cannot 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

writer XmlWriter

The System.Xml.XmlWriter to extend.

value T

The object to serialize.

treeWriter Action<XmlWriter, T, XmlQualifiedEntity>

The delegate used to write the XML hierarchy.

rootEntity XmlQualifiedEntity

The optional XmlQualifiedEntity that will provide the name of the root element.

Type Parameters

T

The type of the object to serialize.

Exceptions

System.ArgumentNullException

writer cannot be null.