Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

XmlObjectSerializer Class

Provides the base class used to serialize objects as XML streams or documents. This class is abstract.

System.Object
  System.Runtime.Serialization.XmlObjectSerializer
    System.Runtime.Serialization.DataContractSerializer

Namespace:  System.Runtime.Serialization
Assembly:  System.Runtime.Serialization (in System.Runtime.Serialization.dll)
public abstract class XmlObjectSerializer

The XmlObjectSerializer type exposes the following members.

  NameDescription
Protected methodSupported by Silverlight for Windows PhoneXmlObjectSerializerInitializes a new instance of the XmlObjectSerializer class.
Top
  NameDescription
Public methodSupported by Silverlight for Windows PhoneEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneFinalizeAllows 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 PhoneGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneIsStartObject(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 PhoneIsStartObject(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 PhoneMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneReadObject(Stream)Reads the XML stream or document with a Stream and returns the deserialized object.
Public methodSupported by Silverlight for Windows PhoneReadObject(XmlDictionaryReader)Reads the XML document or stream with an XmlDictionaryReader and returns the deserialized object.
Public methodSupported by Silverlight for Windows PhoneReadObject(XmlReader)Reads the XML document or stream with an XmlReader and returns the deserialized object.
Public methodSupported by Silverlight for Windows PhoneReadObject(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 PhoneReadObject(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 PhoneToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneWriteEndObject(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 PhoneWriteEndObject(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 PhoneWriteObject(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 PhoneWriteObject(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 PhoneWriteObject(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 PhoneWriteObjectContent(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 PhoneWriteObjectContent(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 PhoneWriteStartObject(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 PhoneWriteStartObject(XmlWriter, Object)Writes the start of the object's data as an opening XML element using the specified XmlWriter.
Top
ExceptionCondition
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.

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.

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

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.