Table of Contents

Class DynamicXmlConverter

Namespace
Cuemon.Xml.Serialization
Assembly
Cuemon.Xml.dll

Provides a factory based way to create and wrap an XmlConverter implementation.

public static class DynamicXmlConverter
Inheritance
Object
DynamicXmlConverter

Methods

Create(Type, Action<XmlWriter, Object, XmlQualifiedEntity>, Func<XmlReader, Type, Object>, Func<Type, Boolean>, XmlQualifiedEntity)

Creates a dynamic instance of an XmlConverter implementation wrapping WriteXml(XmlWriter, Object, XmlQualifiedEntity) through writer and ReadXml(XmlReader, Type) through reader.

public static XmlConverter Create(Type objectType, Action<XmlWriter, object, XmlQualifiedEntity> writer = null, Func<XmlReader, Type, object> reader = null, Func<Type, bool> canConvertPredicate = null, XmlQualifiedEntity rootEntity = null)

Parameters

objectType Type

The type of the object to make convertible.

writer Action<XmlWriter, Object, XmlQualifiedEntity>

The delegate that converts an object to its XML representation.

reader Func<XmlReader, Type, Object>

The delegate that generates an object from its XML representation.

canConvertPredicate Func<Type, Boolean>

The predicate that determines if an XmlConverter can convert.

rootEntity XmlQualifiedEntity

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

Returns

XmlConverter

An XmlConverter implementation of an object.

Create<T>(Action<XmlWriter, T, XmlQualifiedEntity>, Func<XmlReader, Type, T>, Func<Type, Boolean>, XmlQualifiedEntity)

Creates a dynamic instance of an XmlConverter implementation wrapping WriteXml(XmlWriter, Object, XmlQualifiedEntity) through writer and ReadXml(XmlReader, Type) through reader.

public static XmlConverter Create<T>(Action<XmlWriter, T, XmlQualifiedEntity> writer = null, Func<XmlReader, Type, T> reader = null, Func<Type, bool> canConvertPredicate = null, XmlQualifiedEntity rootEntity = null)

Parameters

writer Action<XmlWriter, T, XmlQualifiedEntity>

The delegate that converts T to its XML representation.

reader Func<XmlReader, Type, T>

The delegate that generates T from its XML representation.

canConvertPredicate Func<Type, Boolean>

The predicate that determines if an XmlConverter can convert.

rootEntity XmlQualifiedEntity

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

Returns

XmlConverter

An XmlConverter implementation of T.

Type Parameters

T

The type to implement an XmlConverter.