System.Xml.Serialization.IXmlSerializable

Provides custom formatting for XML serialization and deserialization.

See Also: IXmlSerializable Members

Syntax

public interface IXmlSerializable

Remarks

There are two reasons to implement this interface. The first is to control how your object is serialized or deserialized by the System.Xml.Serialization.XmlSerializer. For example, you can chunk data into bytes instead of buffering large data sets, and also avoid the inflation that occurs when the data is encoded using Base64 encoding. To control the serialization, implement the IXmlSerializable.ReadXml(System.Xml.XmlReader) and IXmlSerializable.WriteXml(System.Xml.XmlWriter) methods to control the System.Xml.XmlReader and System.Xml.XmlWriter classes used to read and write the XML. For an example of this, see How To: Chunk Serialized Data.

The second reason is to be able to control the schema. To enable this, you must apply the System.Xml.Serialization.XmlSchemaProviderAttribute to the serializable type, and specify the name of the static member that returns the schema. See the System.Xml.Serialization.XmlSchemaProviderAttribute for an example.

A class that implements the interface must have a parameterless constructor. This is a requirement of the System.Xml.Serialization.XmlSerializer class.

Requirements

Namespace: System.Xml.Serialization
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0