Class XmlWriterDecoratorExtensions
Extension methods for the XmlWriter class hidden behind the IDecorator<T> interface.
public static class XmlWriterDecoratorExtensions
- Inheritance
-
XmlWriterDecoratorExtensions
Methods
WriteEncapsulatingElementIfNotNull<T>(IDecorator<XmlWriter>, T, XmlQualifiedEntity, Action<XmlWriter, T>)
Writes the specified value with the delegate nodeWriter to the enclosed XmlWriter of the specified decorator.
If elementName is not null, then the delegate nodeWriter is called from within an encapsulating Start- and End-element.
public static void WriteEncapsulatingElementIfNotNull<T>(this IDecorator<XmlWriter> decorator, T value, XmlQualifiedEntity elementName, Action<XmlWriter, T> nodeWriter)
Parameters
decoratorIDecorator<XmlWriter>The IDecorator{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
decoratorcannot be null.
WriteObject(IDecorator<XmlWriter>, object, Type, Action<XmlFormatterOptions>)
Serializes the specified value into an XML format of the enclosed XmlWriter of the specified decorator.
public static void WriteObject(this IDecorator<XmlWriter> decorator, object value, Type objectType, Action<XmlFormatterOptions> setup = null)
Parameters
decoratorIDecorator<XmlWriter>The IDecorator{XmlWriter} to extend.
valueobjectThe object to serialize.
objectTypeTypeThe type of the object to serialize.
setupAction<XmlFormatterOptions>The XmlFormatterOptions which may be configured.
Exceptions
- ArgumentNullException
decoratorcannot be null.
WriteObject<T>(IDecorator<XmlWriter>, T, Action<XmlFormatterOptions>)
Serializes the specified value into an XML format of the enclosed XmlWriter of the specified decorator.
public static void WriteObject<T>(this IDecorator<XmlWriter> decorator, T value, Action<XmlFormatterOptions> setup = null)
Parameters
decoratorIDecorator<XmlWriter>The IDecorator{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
decoratorcannot be null.
WriteStartElement(IDecorator<XmlWriter>, XmlQualifiedEntity)
Writes the specified start tag and associates it with the given elementName of the enclosed XmlWriter of the specified decorator.
public static void WriteStartElement(this IDecorator<XmlWriter> decorator, XmlQualifiedEntity elementName)
Parameters
decoratorIDecorator<XmlWriter>The IDecorator{XmlWriter} to extend.
elementNameXmlQualifiedEntityThe fully qualified name of the element.
Exceptions
- ArgumentNullException
decoratorcannot be null.
WriteXmlRootElement<T>(IDecorator<XmlWriter>, T, Action<XmlWriter, T, XmlQualifiedEntity>, XmlQualifiedEntity)
Writes the XML root element to the enclosed XmlWriter of the specified decorator.
public static void WriteXmlRootElement<T>(this IDecorator<XmlWriter> decorator, T value, Action<XmlWriter, T, XmlQualifiedEntity> treeWriter, XmlQualifiedEntity rootEntity = null)
Parameters
decoratorIDecorator<XmlWriter>The IDecorator{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
decoratorcannot be null.