XmlObjectSerializer Class
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Provides the base class used to serialize objects as XML streams or documents. This class is abstract.
Inheritance Hierarchy
System.Object
System.Runtime.Serialization.XmlObjectSerializer
System.Runtime.Serialization.DataContractSerializer
Namespace: System.Runtime.Serialization
Assembly: System.Runtime.Serialization (in System.Runtime.Serialization.dll)
Syntax
'Declaration
Public MustInherit Class XmlObjectSerializer
public abstract class XmlObjectSerializer
The XmlObjectSerializer type exposes the following members.
Constructors
Name | Description | |
---|---|---|
XmlObjectSerializer | Initializes a new instance of the XmlObjectSerializer class. |
Top
Methods
Name | Description | |
---|---|---|
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
IsStartObject(XmlDictionaryReader) | Gets a value that specifies whether the XmlDictionaryReader is positioned over an XML element that can be read. | |
IsStartObject(XmlReader) | Gets a value that specifies whether the XmlReader is positioned over an XML element that can be read. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ReadObject(Stream) | Reads the XML stream or document with a Stream and returns the deserialized object. | |
ReadObject(XmlDictionaryReader) | Reads the XML document or stream with an XmlDictionaryReader and returns the deserialized object. | |
ReadObject(XmlReader) | Reads the XML document or stream with an XmlReader and returns the deserialized object. | |
ReadObject(XmlDictionaryReader, Boolean) | When implemented in a derived class, reads the XML stream or document with an XmlDictionaryReader and returns the deserialized object. | |
ReadObject(XmlReader, Boolean) | Reads the XML document or stream with an XmlReader and returns the deserialized object. It also enables you to specify whether the serializer can read the data before attempting to read it. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
WriteEndObject(XmlDictionaryWriter) | Writes the end of the object data as a closing XML element to the XML document or stream with an XmlDictionaryWriter. | |
WriteEndObject(XmlWriter) | Writes the end of the object data as a closing XML element to the XML document or stream with an XmlWriter. | |
WriteObject(Stream, Object) | Writes the complete content (start, content, and end) of the object to the XML document or stream with the specified Stream. | |
WriteObject(XmlDictionaryWriter, Object) | Writes the complete content (start, content, and end) of the object to the XML document or stream with the specified XmlDictionaryWriter. | |
WriteObject(XmlWriter, Object) | Writes the complete content (start, content, and end) of the object to the XML document or stream with the specified XmlWriter. | |
WriteObjectContent(XmlDictionaryWriter, Object) | Writes only the content of the object to the XML document or stream using the specified XmlDictionaryWriter. | |
WriteObjectContent(XmlWriter, Object) | Writes only the content of the object to the XML document or stream with the specified XmlWriter. | |
WriteStartObject(XmlDictionaryWriter, Object) | Writes the start of the object's data as an opening XML element using the specified XmlDictionaryWriter. | |
WriteStartObject(XmlWriter, Object) | Writes the start of the object's data as an opening XML element using the specified XmlWriter. |
Top
Exceptions
Exception | Condition |
---|---|
InvalidDataContractException | The type being serialized does not conform to data contract rules. For example, the DataContractAttribute attribute has not been applied to the type. |
SerializationException | There is a problem with the instance being serialized. |
Remarks
Extend the XmlObjectSerializer to create your own serializer to serialize and deserialize objects. Both the DataContractSerializer class inherits from the XmlObjectSerializer and are used to serialize and deserialize objects that conform to data contract rules (objects created using the DataContractAttribute and the DataMemberAttribute).
Notes to Inheritors
When you inherit from XmlObjectSerializer, you must override the following members: XmlObjectSerializer.WriteStartObject(XmlDictionaryWriter, Object), XmlObjectSerializer.WriteObjectContent(XmlDictionaryWriter, Object), and XmlObjectSerializer.WriteEndObject(XmlDictionaryWriter). Additionally, the IsStartObject and ReadObject methods must be implemented for reading and deserializing.
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.