Class XmlConverterExtensions
- Assembly
- Cuemon.Extensions.Xml.dll
Extension methods for the XmlConverter class.
public static class XmlConverterExtensions
- Inheritance
-
XmlConverterExtensions
Methods
AddDateTimeConverter(IList<XmlConverter>)
Adds an DateTime XML converter to the list.
public static IList<XmlConverter> AddDateTimeConverter(this IList<XmlConverter> converters)
Parameters
converters
IList<XmlConverter>The IList{XmlConverter} to extend.
Returns
- IList<XmlConverter>
A reference to
converters
after the operation has completed.
Exceptions
- ArgumentNullException
converters
cannot be null.
AddEnumerableConverter(IList<XmlConverter>)
Adds an IEnumerable XML converter to the list.
public static IList<XmlConverter> AddEnumerableConverter(this IList<XmlConverter> converters)
Parameters
converters
IList<XmlConverter>The IList{XmlConverter} to extend.
Returns
- IList<XmlConverter>
A reference to
converters
after the operation has completed.
Exceptions
- ArgumentNullException
converters
cannot be null.
AddExceptionConverter(IList<XmlConverter>, Boolean, Boolean)
Adds an Exception XML converter to the list.
public static IList<XmlConverter> AddExceptionConverter(this IList<XmlConverter> converters, bool includeStackTrace, bool includeData)
Parameters
converters
IList<XmlConverter>The IList{XmlConverter} to extend.
includeStackTrace
BooleanThe value that determine whether the stack of an exception is included in the converted result.
includeData
BooleanThe value that determine whether the data of an exception is included in the converted result.
Returns
- IList<XmlConverter>
A reference to
converters
after the operation has completed.
Exceptions
- ArgumentNullException
converters
cannot be null.
AddExceptionDescriptorConverter(IList<XmlConverter>, Action<ExceptionDescriptorOptions>)
Adds an ExceptionDescriptor XML converter to the list.
public static IList<XmlConverter> AddExceptionDescriptorConverter(this IList<XmlConverter> converters, Action<ExceptionDescriptorOptions> setup)
Parameters
converters
IList<XmlConverter>The IList{XmlConverter} to extend.
setup
Action<ExceptionDescriptorOptions>The ExceptionDescriptorOptions which need to be configured.
Returns
- IList<XmlConverter>
A reference to
converters
after the operation has completed.
Exceptions
- ArgumentNullException
converters
cannot be null.
AddFailureConverter(IList<XmlConverter>)
Adds an Failure XML converter to the list.
public static IList<XmlConverter> AddFailureConverter(this IList<XmlConverter> converters)
Parameters
converters
IList<XmlConverter>The IList{XmlConverter} to extend.
Returns
- IList<XmlConverter>
A reference to
converters
after the operation has completed.
Exceptions
- ArgumentNullException
converters
cannot be null.
AddStringConverter(IList<XmlConverter>)
Adds an String XML converter to the list.
public static IList<XmlConverter> AddStringConverter(this IList<XmlConverter> converters)
Parameters
converters
IList<XmlConverter>The IList{XmlConverter} to extend.
Returns
- IList<XmlConverter>
A reference to
converters
after the operation has completed.
Exceptions
- ArgumentNullException
converters
cannot be null.
AddTimeSpanConverter(IList<XmlConverter>)
Adds an TimeSpan XML converter to the list.
public static IList<XmlConverter> AddTimeSpanConverter(this IList<XmlConverter> converters)
Parameters
converters
IList<XmlConverter>The IList{XmlConverter} to extend.
Returns
- IList<XmlConverter>
A reference to
converters
after the operation has completed.
Exceptions
- ArgumentNullException
converters
cannot be null.
AddUriConverter(IList<XmlConverter>)
Adds a Uri XML converter to the list.
public static IList<XmlConverter> AddUriConverter(this IList<XmlConverter> converters)
Parameters
converters
IList<XmlConverter>The IList{XmlConverter} to extend.
Returns
- IList<XmlConverter>
A reference to
converters
after the operation has completed.
Exceptions
- ArgumentNullException
converters
cannot be null.
AddXmlConverter<T>(IList<XmlConverter>, Action<XmlWriter, T, XmlQualifiedEntity>, Func<XmlReader, Type, T>, Func<Type, Boolean>, XmlQualifiedEntity)
Adds an XML converter to the list.
public static IList<XmlConverter> AddXmlConverter<T>(this IList<XmlConverter> converters, Action<XmlWriter, T, XmlQualifiedEntity> writer = null, Func<XmlReader, Type, T> reader = null, Func<Type, bool> canConvertPredicate = null, XmlQualifiedEntity qe = null)
Parameters
converters
IList<XmlConverter>The 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
XmlQualifiedEntityThe optional XmlQualifiedEntity that will provide the name of the root element.
Returns
- IList<XmlConverter>
A reference to
converters
after the operation has completed.
Type Parameters
T
The type of the object to converts to and from XML.
Exceptions
- ArgumentNullException
converters
cannot be null.
FirstOrDefaultReaderConverter(IList<XmlConverter>, Type)
Returns the first XmlConverter of the converters
that CanConvert(Type) and CanRead the specified objectType
; otherwise null
if no XmlConverter is found.
public static XmlConverter FirstOrDefaultReaderConverter(this IList<XmlConverter> converters, Type objectType)
Parameters
converters
IList<XmlConverter>The IList{XmlConverter} to extend.
objectType
TypeType of the object to deserialize.
Returns
- XmlConverter
An XmlConverter that can deserialize the specified
objectType
; otherwisenull
.
Exceptions
- ArgumentNullException
converters
cannot be null.
FirstOrDefaultWriterConverter(IList<XmlConverter>, Type)
Returns the first XmlConverter of the converters
that CanConvert(Type) and CanWrite the specified objectType
; otherwise null
if no XmlConverter is found.
public static XmlConverter FirstOrDefaultWriterConverter(this IList<XmlConverter> converters, Type objectType)
Parameters
converters
IList<XmlConverter>The IList{XmlConverter} to extend.
objectType
TypeType of the object to serialize.
Returns
- XmlConverter
An XmlConverter that can serialize the specified
objectType
; otherwisenull
.
Exceptions
- ArgumentNullException
converters
cannot be null.
InsertXmlConverter<T>(IList<XmlConverter>, Int32, Action<XmlWriter, T, XmlQualifiedEntity>, Func<XmlReader, Type, T>, Func<Type, Boolean>, XmlQualifiedEntity)
Inserts an XML converter to the list at the specified index
.
public static IList<XmlConverter> InsertXmlConverter<T>(this IList<XmlConverter> converters, int index, Action<XmlWriter, T, XmlQualifiedEntity> writer = null, Func<XmlReader, Type, T> reader = null, Func<Type, bool> canConvertPredicate = null, XmlQualifiedEntity qe = null)
Parameters
converters
IList<XmlConverter>The IList{XmlConverter} to extend.
index
Int32The 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
XmlQualifiedEntityThe optional XmlQualifiedEntity that will provide the name of the root element.
Returns
- IList<XmlConverter>
A reference to
converters
after the operation has completed.
Type Parameters
T
The type of the object to converts to and from XML.
Exceptions
- ArgumentNullException
converters
cannot be null.