Table of Contents

Class XmlConverterDecoratorExtensions

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

Extension methods for the XmlConverter class hidden behind the IDecorator<T> interface.

public static class XmlConverterDecoratorExtensions
Inheritance
Object
XmlConverterDecoratorExtensions

Methods

AddDateTimeConverter(IDecorator<IList<XmlConverter>>)

Adds an System.DateTime XML converter to the enclosed IList{XmlConverter} of the specified decorator.

public static IDecorator<IList<XmlConverter>> AddDateTimeConverter(this IDecorator<IList<XmlConverter>> decorator)

Parameters

decorator IDecorator<IList<XmlConverter>>

The IDecorator{IList{XmlConverter}} to extend.

Returns

IDecorator<IList<XmlConverter>>

A reference to decorator after the operation has completed.

Exceptions

System.ArgumentNullException

decorator cannot be null.

AddEnumerableConverter(IDecorator<IList<XmlConverter>>)

Adds an System.Collections.IEnumerable XML converter to the enclosed IList{XmlConverter} of the specified decorator.

public static IDecorator<IList<XmlConverter>> AddEnumerableConverter(this IDecorator<IList<XmlConverter>> decorator)

Parameters

decorator IDecorator<IList<XmlConverter>>

The IDecorator{IList{XmlConverter}} to extend.

Returns

IDecorator<IList<XmlConverter>>

A reference to decorator after the operation has completed.

Exceptions

System.ArgumentNullException

decorator cannot be null.

AddExceptionConverter(IDecorator<IList<XmlConverter>>, Boolean, Boolean)

Adds an System.Exception XML converter to the enclosed IList{XmlConverter} of the specified decorator.

public static IDecorator<IList<XmlConverter>> AddExceptionConverter(this IDecorator<IList<XmlConverter>> decorator, bool includeStackTrace, bool includeData)

Parameters

decorator IDecorator<IList<XmlConverter>>

The IDecorator{IList{XmlConverter}} to extend.

includeStackTrace Boolean

The value that determine whether the stack of an exception is included in the converted result.

includeData Boolean

The value that determine whether the data of an exception is included in the converted result.

Returns

IDecorator<IList<XmlConverter>>

A reference to decorator after the operation has completed.

Exceptions

System.ArgumentNullException

decorator cannot be null.

AddExceptionDescriptorConverter(IDecorator<IList<XmlConverter>>, Action<ExceptionDescriptorOptions>)

Adds an ExceptionDescriptor XML converter to the enclosed IList{XmlConverter} of the specified decorator.

public static IDecorator<IList<XmlConverter>> AddExceptionDescriptorConverter(this IDecorator<IList<XmlConverter>> decorator, Action<ExceptionDescriptorOptions> setup)

Parameters

decorator IDecorator<IList<XmlConverter>>

The IDecorator{IList{XmlConverter}} to extend.

setup Action<ExceptionDescriptorOptions>

The ExceptionDescriptorOptions which need to be configured.

Returns

IDecorator<IList<XmlConverter>>

A reference to decorator after the operation has completed.

Exceptions

System.ArgumentNullException

decorator cannot be null.

AddStringConverter(IDecorator<IList<XmlConverter>>)

Adds an System.String XML converter to the enclosed IList{XmlConverter} of the specified decorator.

public static IDecorator<IList<XmlConverter>> AddStringConverter(this IDecorator<IList<XmlConverter>> decorator)

Parameters

decorator IDecorator<IList<XmlConverter>>

The IDecorator{IList{XmlConverter}} to extend.

Returns

IDecorator<IList<XmlConverter>>

A reference to decorator after the operation has completed.

Exceptions

System.ArgumentNullException

decorator cannot be null.

AddTimeSpanConverter(IDecorator<IList<XmlConverter>>)

Adds an System.TimeSpan XML converter to the enclosed IList{XmlConverter} of the specified decorator.

public static IDecorator<IList<XmlConverter>> AddTimeSpanConverter(this IDecorator<IList<XmlConverter>> decorator)

Parameters

decorator IDecorator<IList<XmlConverter>>

The IDecorator{IList{XmlConverter}} to extend.

Returns

IDecorator<IList<XmlConverter>>

A reference to decorator after the operation has completed.

Exceptions

System.ArgumentNullException

decorator cannot be null.

AddUriConverter(IDecorator<IList<XmlConverter>>)

Adds a System.Uri XML converter to the enclosed IList{XmlConverter} of the specified decorator.

public static IDecorator<IList<XmlConverter>> AddUriConverter(this IDecorator<IList<XmlConverter>> decorator)

Parameters

decorator IDecorator<IList<XmlConverter>>

The IDecorator{IList{XmlConverter}} to extend.

Returns

IDecorator<IList<XmlConverter>>

A reference to decorator after the operation has completed.

Exceptions

System.ArgumentNullException

decorator cannot be null.

AddXmlConverter<T>(IDecorator<IList<XmlConverter>>, Action<XmlWriter, T, XmlQualifiedEntity>, Func<XmlReader, Type, T>, Func<Type, Boolean>, XmlQualifiedEntity)

Adds an XML converter to the enclosed IList{XmlConverter} of the specified decorator.

public static IDecorator<IList<XmlConverter>> AddXmlConverter<T>(this IDecorator<IList<XmlConverter>> decorator, Action<XmlWriter, T, XmlQualifiedEntity> writer = null, Func<XmlReader, Type, T> reader = null, Func<Type, bool> canConvertPredicate = null, XmlQualifiedEntity qe = null)

Parameters

decorator IDecorator<IList<XmlConverter>>

The IDecorator{IList{XmlConverter}} to extend.

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 delegate that determines if an object can be converted.

qe XmlQualifiedEntity

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

Returns

IDecorator<IList<XmlConverter>>

A reference to decorator after the operation has completed.

Type Parameters

T

The type of the object to converts to and from XML.

Exceptions

System.ArgumentNullException

decorator cannot be null.

FirstOrDefaultReaderConverter(IDecorator<IList<XmlConverter>>, Type)

Returns the first XmlConverter of the enclosed IList{XmlConverter} of the specified decorator that CanConvert(Type) and CanRead the specified objectType; otherwise null if no XmlConverter is found.

public static XmlConverter FirstOrDefaultReaderConverter(this IDecorator<IList<XmlConverter>> decorator, Type objectType)

Parameters

decorator IDecorator<IList<XmlConverter>>

The IDecorator{IList{XmlConverter}} to extend.

objectType Type

Type of the object to deserialize.

Returns

XmlConverter

An XmlConverter that can deserialize the specified objectType; otherwise null.

Exceptions

System.ArgumentNullException

decorator cannot be null.

FirstOrDefaultWriterConverter(IDecorator<IList<XmlConverter>>, Type)

Returns the first XmlConverter of the enclosed IList{XmlConverter} of the specified decorator that CanConvert(Type) and CanWrite the specified objectType; otherwise null if no XmlConverter is found.

public static XmlConverter FirstOrDefaultWriterConverter(this IDecorator<IList<XmlConverter>> decorator, Type objectType)

Parameters

decorator IDecorator<IList<XmlConverter>>

The IDecorator{IList{XmlConverter}} to extend.

objectType Type

Type of the object to serialize.

Returns

XmlConverter

An XmlConverter that can serialize the specified objectType; otherwise null.

Exceptions

System.ArgumentNullException

decorator cannot be null.

InsertXmlConverter<T>(IDecorator<IList<XmlConverter>>, Int32, Action<XmlWriter, T, XmlQualifiedEntity>, Func<XmlReader, Type, T>, Func<Type, Boolean>, XmlQualifiedEntity)

Inserts an XML converter to the enclosed IList{XmlConverter} of the specified decorator at the specified index.

public static IDecorator<IList<XmlConverter>> InsertXmlConverter<T>(this IDecorator<IList<XmlConverter>> decorator, int index, Action<XmlWriter, T, XmlQualifiedEntity> writer = null, Func<XmlReader, Type, T> reader = null, Func<Type, bool> canConvertPredicate = null, XmlQualifiedEntity qe = null)

Parameters

decorator IDecorator<IList<XmlConverter>>

The IDecorator{IList{XmlConverter}} to extend.

index Int32

The zero-based index at which an XML converter should be inserted.

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 delegate that determines if an object can be converted.

qe XmlQualifiedEntity

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

Returns

IDecorator<IList<XmlConverter>>

A reference to decorator after the operation has completed.

Type Parameters

T

The type of the object to converts to and from XML.

Exceptions

System.ArgumentNullException

decorator cannot be null.

See Also