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
writer
XmlWriterThe XmlWriter to extend.
value
TThe object to serialize.
elementName
XmlQualifiedEntityThe 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
- 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
XmlWriterThe XmlWriter to extend.
value
ObjectThe object to serialize.
objectType
TypeThe type of the object to serialize.
setup
Action<XmlFormatterOptions>The XmlFormatterOptions which may be configured.
Exceptions
- 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
XmlWriterThe XmlWriter to extend.
value
TThe object to serialize.
setup
Action<XmlFormatterOptions>The XmlFormatterOptions which may be configured.
Type Parameters
T
The type of the object to serialize.
Exceptions
- 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
XmlWriterThe XmlWriter to extend.
elementName
XmlQualifiedEntityThe fully qualified name of the element.
Exceptions
- 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
XmlWriterThe XmlWriter to extend.
value
TThe object to serialize.
treeWriter
Action<XmlWriter, T, XmlQualifiedEntity>The delegate used to write the XML hierarchy.
rootEntity
XmlQualifiedEntityThe optional XmlQualifiedEntity that will provide the name of the root element.
Type Parameters
T
The type of the object to serialize.
Exceptions
- ArgumentNullException
writer
cannot be null.