Table of Contents

Create Method

Definition

Create<T>(Action<XmlWriter, T, XmlQualifiedEntity>, Func<XmlReader, Type, T>, Func<Type, bool>, 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, bool>

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.

Create(Type, Action<XmlWriter, object, XmlQualifiedEntity>, Func<XmlReader, Type, object>, Func<Type, bool>, 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, bool>

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.