XmlObjectSerializer Class

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
Protected methodSupported by Silverlight for Windows Phone XmlObjectSerializer Initializes a new instance of the XmlObjectSerializer class.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows Phone Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone 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.)
Public methodSupported by Silverlight for Windows Phone GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetType Gets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone IsStartObject(XmlDictionaryReader) Gets a value that specifies whether the XmlDictionaryReader is positioned over an XML element that can be read.
Public methodSupported by Silverlight for Windows Phone IsStartObject(XmlReader) Gets a value that specifies whether the XmlReader is positioned over an XML element that can be read.
Protected methodSupported by Silverlight for Windows Phone MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone ReadObject(Stream) Reads the XML stream or document with a Stream and returns the deserialized object.
Public methodSupported by Silverlight for Windows Phone ReadObject(XmlDictionaryReader) Reads the XML document or stream with an XmlDictionaryReader and returns the deserialized object.
Public methodSupported by Silverlight for Windows Phone ReadObject(XmlReader) Reads the XML document or stream with an XmlReader and returns the deserialized object.
Public methodSupported by Silverlight for Windows Phone ReadObject(XmlDictionaryReader, Boolean) When implemented in a derived class, reads the XML stream or document with an XmlDictionaryReader and returns the deserialized object.
Public methodSupported by Silverlight for Windows Phone 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.
Public methodSupported by Silverlight for Windows Phone ToString Returns a string that represents the current object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone WriteEndObject(XmlDictionaryWriter) Writes the end of the object data as a closing XML element to the XML document or stream with an XmlDictionaryWriter.
Public methodSupported by Silverlight for Windows Phone WriteEndObject(XmlWriter) Writes the end of the object data as a closing XML element to the XML document or stream with an XmlWriter.
Public methodSupported by Silverlight for Windows Phone WriteObject(Stream, Object) Writes the complete content (start, content, and end) of the object to the XML document or stream with the specified Stream.
Public methodSupported by Silverlight for Windows Phone WriteObject(XmlDictionaryWriter, Object) Writes the complete content (start, content, and end) of the object to the XML document or stream with the specified XmlDictionaryWriter.
Public methodSupported by Silverlight for Windows Phone WriteObject(XmlWriter, Object) Writes the complete content (start, content, and end) of the object to the XML document or stream with the specified XmlWriter.
Public methodSupported by Silverlight for Windows Phone WriteObjectContent(XmlDictionaryWriter, Object) Writes only the content of the object to the XML document or stream using the specified XmlDictionaryWriter.
Public methodSupported by Silverlight for Windows Phone WriteObjectContent(XmlWriter, Object) Writes only the content of the object to the XML document or stream with the specified XmlWriter.
Public methodSupported by Silverlight for Windows Phone WriteStartObject(XmlDictionaryWriter, Object) Writes the start of the object's data as an opening XML element using the specified XmlDictionaryWriter.
Public methodSupported by Silverlight for Windows Phone 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.