Class ExtensionMethodsForXml
Extension methods that assist or enable functionality found within the extension model namespace for xml-specific behaviors (ExtendedXmlSerializer.ExtensionModel.Xml).
Inheritance
Inherited Members
Namespace: ExtendedXmlSerializer
Assembly: ExtendedXmlSerializer.dll
Syntax
public static class ExtensionMethodsForXml
Methods
AddMigration(ITypeConfiguration, ICommand<XElement>)
Adds a migration command to the configured type. A migration allows older persisted XML to migrate to an object model schema that has changed since the XML was persisted. The provided command specifies how to manipulate the element that represents the type so that it can (hopefully 😇) be deserialized without error.
Declaration
public static ITypeConfiguration AddMigration(this ITypeConfiguration this, ICommand<XElement> migration)
Parameters
ITypeConfiguration
this
The type configuration to configure. |
ICommand<System.Xml.Linq.XElement>
migration
The command that specifies how to migrate an Xml element that represents an older schema. |
Returns
ITypeConfiguration
The configured type configuration. |
AddMigration(ITypeConfiguration, Action<XElement>)
Adds a migration delegate to the configured type. A migration allows older persisted XML to migrate to an object model schema that has changed since the XML was persisted. The provided command specifies how to manipulate the element that represents the type so that it can (hopefully 😇) be deserialized without error.
Declaration
public static ITypeConfiguration AddMigration(this ITypeConfiguration this, Action<XElement> migration)
Parameters
ITypeConfiguration
this
The type configuration to configure. |
System.Action<System.Xml.Linq.XElement>
migration
The delegate that specifies how to migrate an Xml element that represents an older schema. |
Returns
ITypeConfiguration
The configured type configuration. |
AddMigration(ITypeConfiguration, IEnumerable<Action<XElement>>)
Adds a set of migration delegates to the configured type. A migration allows older persisted XML to migrate to an object model schema that has changed since the XML was persisted. The provided command specifies how to manipulate the element that represents the type so that it can (hopefully 😇) be deserialized without error.
Declaration
public static ITypeConfiguration AddMigration(this ITypeConfiguration this, IEnumerable<Action<XElement>> migrations)
Parameters
ITypeConfiguration
this
The type configuration to configure. |
System.Collections.Generic.IEnumerable<System.Action<System.Xml.Linq.XElement>>
migrations
The delegates that specify how to migrate an Xml element that represents an older schema. |
Returns
ITypeConfiguration
The configured type configuration. |
AddMigration<T>(ITypeConfiguration<T>, ICommand<XElement>)
Adds a migration command to the configured type. A migration allows older persisted XML to migrate to an object model schema that has changed since the XML was persisted. The provided command specifies how to manipulate the element that represents the type so that it can (hopefully 😇) be deserialized without error.
Declaration
public static ITypeConfiguration<T> AddMigration<T>(this ITypeConfiguration<T> this, ICommand<XElement> migration)
Parameters
ITypeConfiguration<T>
this
The type configuration to configure. |
ICommand<System.Xml.Linq.XElement>
migration
The command that specifies how to migrate an Xml element that represents an older schema. |
Returns
ITypeConfiguration<T>
The configured type configuration. |
Type Parameters
T
The type under configuration. |
AddMigration<T>(ITypeConfiguration<T>, Action<XElement>)
Adds a migration delegate to the configured type. A migration allows older persisted XML to migrate to an object model schema that has changed since the XML was persisted. The provided command specifies how to manipulate the element that represents the type so that it can (hopefully 😇) be deserialized without error.
Declaration
public static ITypeConfiguration<T> AddMigration<T>(this ITypeConfiguration<T> this, Action<XElement> migration)
Parameters
ITypeConfiguration<T>
this
The type configuration to configure. |
System.Action<System.Xml.Linq.XElement>
migration
The delegate that specifies how to migrate an Xml element that represents an older schema. |
Returns
ITypeConfiguration<T>
The configured type configuration. |
Type Parameters
T
The type under configuration. |
AddMigration<T>(ITypeConfiguration<T>, IEnumerable<Action<XElement>>)
Adds a set of migration delegates to the configured type. A migration allows older persisted XML to migrate to an object model schema that has changed since the XML was persisted. The provided command specifies how to manipulate the element that represents the type so that it can (hopefully 😇) be deserialized without error.
Declaration
public static ITypeConfiguration<T> AddMigration<T>(this ITypeConfiguration<T> this, IEnumerable<Action<XElement>> migrations)
Parameters
ITypeConfiguration<T>
this
The type configuration to configure. |
System.Collections.Generic.IEnumerable<System.Action<System.Xml.Linq.XElement>>
migrations
The delegates that specify how to migrate an Xml element that represents an older schema. |
Returns
ITypeConfiguration<T>
The configured type configuration. |
Type Parameters
T
The type under configuration. |
Attribute<T, TMember>(IMemberConfiguration<T, TMember>)
Configures the specified member to emit as an Xml attribute, rather than as an element.
Declaration
public static IMemberConfiguration<T, TMember> Attribute<T, TMember>(this IMemberConfiguration<T, TMember> this)
Parameters
IMemberConfiguration<T, TMember>
this
The member configuration to configure. |
Returns
IMemberConfiguration<T, TMember>
The configured member configuration. |
Type Parameters
T
The member's containing type. |
TMember
The value type of the member. |
Attribute<T, TMember>(IMemberConfiguration<T, TMember>, Func<TMember, Boolean>)
Configures the specified member to emit as an Xml attribute when the provided condition is met, rather than as an element. When the provided condition delegate evaluates as true, the member is emitted as an Xml attribute. Otherwise, it emits as an Xml element.
Declaration
public static IMemberConfiguration<T, TMember> Attribute<T, TMember>(this IMemberConfiguration<T, TMember> this, Func<TMember, bool> when)
Parameters
IMemberConfiguration<T, TMember>
this
The member configuration to configure. |
System.Func<TMember, System.Boolean>
when
The condition used to specify when to render this member as an Xml attribute. |
Returns
IMemberConfiguration<T, TMember>
The configured member configuration. |
Type Parameters
T
The member's containing type. |
TMember
The value type of the member. |
Content<T, TMember>(IMemberConfiguration<T, TMember>)
Forces a member to emit as an Xml element. This is only useful if a member was registered as an attribute and for some reason the member should be further configured to emit as an Xml element instead (effectively delisting it as an Xml attribute). Otherwise, emitting as an Xml element is the default behavior and this method should not be used.
Declaration
public static IMemberConfiguration<T, TMember> Content<T, TMember>(this IMemberConfiguration<T, TMember> this)
Parameters
IMemberConfiguration<T, TMember>
this
The member configuration to configure. |
Returns
IMemberConfiguration<T, TMember>
The configured member configuration. |
Type Parameters
T
The member's containing type. |
TMember
The value type of the member. |
CustomSerializer<T>(IConfigurationContainer, Type)
This is considered v1 functionality and is not supported, although it is not yet considered deprecated. Please
make use of the registration methods instead. The current equivalent for this method call is
IConfigurationContainer.Type{T}.Register().Serializer().Of(serializerType)
.
Declaration
public static ITypeConfiguration<T> CustomSerializer<T>(this IConfigurationContainer this, Type serializerType)
Parameters
IConfigurationContainer
this
|
System.Type
serializerType
|
Returns
ITypeConfiguration<T>
|
Type Parameters
T
|
See Also
CustomSerializer<T>(ITypeConfiguration<T>, IExtendedXmlCustomSerializer)
This is considered v1 functionality and is not supported, although it is not yet considered deprecated. Please
make use of the registration methods instead. The current equivalent for this method call is
IConfigurationContainer.Type{T}.Register().Serializer().Using(serializer)
.
Declaration
public static ITypeConfiguration<T> CustomSerializer<T>(this ITypeConfiguration<T> this, IExtendedXmlCustomSerializer serializer)
Parameters
ITypeConfiguration<T>
this
|
IExtendedXmlCustomSerializer
serializer
|
Returns
ITypeConfiguration<T>
|
Type Parameters
T
|
See Also
CustomSerializer<T>(ITypeConfiguration<T>, IExtendedXmlCustomSerializer<T>)
This is considered v1 functionality and is not supported, although it is not yet considered deprecated. Please
make use of the registration methods instead. The current equivalent for this method call is
IConfigurationContainer.Type{T}.Register().Serializer().Using(serializer)
.
Declaration
public static ITypeConfiguration<T> CustomSerializer<T>(this ITypeConfiguration<T> this, IExtendedXmlCustomSerializer<T> serializer)
Parameters
ITypeConfiguration<T>
this
|
IExtendedXmlCustomSerializer<T>
serializer
|
Returns
ITypeConfiguration<T>
|
Type Parameters
T
|
See Also
CustomSerializer<T>(ITypeConfiguration<T>, Action<XmlWriter, T>, Func<XElement, T>)
This is considered v1 functionality and is not supported, although it is not yet considered deprecated. Please
make use of the registration methods instead. The current equivalent for this method call is
IConfigurationContainer.Type{T}.Register().Serializer().ByCalling(serializer, deserializer)
. Note that the
signatures for the delegates have changed since v1.
Declaration
public static ITypeConfiguration<T> CustomSerializer<T>(this ITypeConfiguration<T> this, Action<XmlWriter, T> serializer, Func<XElement, T> deserialize)
Parameters
ITypeConfiguration<T>
this
|
System.Action<System.Xml.XmlWriter, T>
serializer
|
System.Func<System.Xml.Linq.XElement, T>
deserialize
|
Returns
ITypeConfiguration<T>
|
Type Parameters
T
|
See Also
CustomSerializer<T, TSerializer>(IConfigurationContainer)
This is considered v1 functionality and is not supported, although it is not yet considered deprecated. Please
make use of the registration methods instead. The current equivalent for this method call is
IConfigurationContainer.Type{T}.Register().Serializer().Of{TSerializer}
.
Declaration
public static ITypeConfiguration<T> CustomSerializer<T, TSerializer>(this IConfigurationContainer this)
where TSerializer : IExtendedXmlCustomSerializer<T>
Parameters
IConfigurationContainer
this
|
Returns
ITypeConfiguration<T>
|
Type Parameters
T
|
TSerializer
|
See Also
UseAutoFormatting(IConfigurationContainer)
Configures the provided configuration container to create a serializer that automatically formats its contents into attributes and elements. When a serializer encounters a primitive type (or more accurately, a type that has an IConverter registered to handle it), it will automatically serialize its resulting (string) data as an Xml attribute. The only exception is when a System.String is encountered, where it will check its length. Strings greater than 128 characters will be emitted as inner content. Otherwise, it will be emitted as an Xml attribute.
Declaration
public static IConfigurationContainer UseAutoFormatting(this IConfigurationContainer this)
Parameters
IConfigurationContainer
this
The configuration container to configure. |
Returns
IConfigurationContainer
The configured configuration container. |
UseAutoFormatting(IConfigurationContainer, Int32)
Configures the provided configuration container to create a serializer that automatically formats its contents into attributes and elements. When a serializer encounters a primitive type (or more accurately, a type that has an IConverter registered to handle it), it will automatically serialize its resulting (string) data as an Xml attribute. The only exception is when a System.String is encountered, where it will check its length. Strings greater than the provided max-length will be emitted as inner content. Otherwise, it will be emitted as an Xml attribute.
Declaration
public static IConfigurationContainer UseAutoFormatting(this IConfigurationContainer this, int maxTextLength)
Parameters
IConfigurationContainer
this
The configuration container to configure. |
System.Int32
maxTextLength
The max length a string can be before it is rendered as inner content. Any string shorter than this amount will be rendered as an Xml attribute. |
Returns
IConfigurationContainer
The configured configuration container. |
UseClassicSerialization<T>(ITypeConfiguration<T>)
Used in dire circumstances. If you encounter an older .NET object type that cannot be serialized (e.g. DataTable), and it implements System.Runtime.Serialization.ISerializable, call this method to configure the container to create a serializer that will serialize and deserialize using this interface.
Declaration
public static ITypeConfiguration<T> UseClassicSerialization<T>(this ITypeConfiguration<T> this)
where T : ISerializable
Parameters
ITypeConfiguration<T>
this
The type configuration to configure. |
Returns
ITypeConfiguration<T>
The configured type configuration. |
Type Parameters
T
The type under configuration. |
See Also
UseOptimizedNamespaces(IConfigurationContainer)
Configures the container to create a serializer that consolidates all namespaces so that they emit at the root of the document, rather than throughout the document when they are first encountered (which can lead to a lot of unnecessary overhead and larger documents).
Declaration
public static IConfigurationContainer UseOptimizedNamespaces(this IConfigurationContainer this)
Parameters
IConfigurationContainer
this
The configuration container to configure. |
Returns
IConfigurationContainer
The configured configuration container. |
Verbatim<T>(IMemberConfiguration<T, String>)
Forces a member to emit within a CDATA container so it can render its contents verbatim.
Declaration
public static IMemberConfiguration<T, string> Verbatim<T>(this IMemberConfiguration<T, string> this)
Parameters
IMemberConfiguration<T, System.String>
this
The member configuration to configure. |
Returns
IMemberConfiguration<T, System.String>
The configured member configuration. |
Type Parameters
T
The member's containing type. |
WithValidCharacters(IConfigurationContainer)
Ensures that all text and strings encountered when emitting the document are valid Xml characters, replacing those that are not with empty strings.
Declaration
public static IConfigurationContainer WithValidCharacters(this IConfigurationContainer this)
Parameters
IConfigurationContainer
this
The configuration container to configure. |
Returns
IConfigurationContainer
The configured configuration container. |
See Also
WithValidCharacters<T>(IMemberConfiguration<T, String>)
Ensures that all text and strings encountered when emitting the specified member are valid Xml characters, replacing those that are not with empty strings.
Declaration
public static IMemberConfiguration<T, string> WithValidCharacters<T>(this IMemberConfiguration<T, string> this)
Parameters
IMemberConfiguration<T, System.String>
this
The member configuration to configure. |
Returns
IMemberConfiguration<T, System.String>
The configured member configuration. |
Type Parameters
T
The member's containing type. |