แก้ไข

แชร์ผ่าน


XmlObjectSerializer.ReadObject Method

Definition

Reads an XML document or document stream and returns the deserialized object.

Overloads

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)

Reads the XML stream or document with an XmlDictionaryReader and returns the deserialized object; it also enables you to specify whether the serializer can read the data before attempting to read it.

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.

ReadObject(Stream)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Reads the XML stream or document with a Stream and returns the deserialized object.

public:
 virtual System::Object ^ ReadObject(System::IO::Stream ^ stream);
public virtual object ReadObject (System.IO.Stream stream);
public virtual object? ReadObject (System.IO.Stream stream);
abstract member ReadObject : System.IO.Stream -> obj
override this.ReadObject : System.IO.Stream -> obj
Public Overridable Function ReadObject (stream As Stream) As Object

Parameters

stream
Stream

A Stream used to read the XML stream or document.

Returns

The deserialized object.

Remarks

This method is a virtual method, and has a default implementation that creates a dictionary reader to read the underlying stream and deserialize it. The default implementation assumes the stream is text or XML.

Applies to

ReadObject(XmlDictionaryReader)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Reads the XML document or stream with an XmlDictionaryReader and returns the deserialized object.

public:
 virtual System::Object ^ ReadObject(System::Xml::XmlDictionaryReader ^ reader);
public virtual object ReadObject (System.Xml.XmlDictionaryReader reader);
public virtual object? ReadObject (System.Xml.XmlDictionaryReader reader);
abstract member ReadObject : System.Xml.XmlDictionaryReader -> obj
override this.ReadObject : System.Xml.XmlDictionaryReader -> obj
Public Overridable Function ReadObject (reader As XmlDictionaryReader) As Object

Parameters

reader
XmlDictionaryReader

An XmlDictionaryReader used to read the XML document.

Returns

The deserialized object.

Remarks

This method is a virtual method, and has a default implementation that creates a dictionary reader to read the underlying stream and deserialize it. The default implementation assumes the stream is text or XML.

Applies to

ReadObject(XmlReader)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Reads the XML document or stream with an XmlReader and returns the deserialized object.

public:
 virtual System::Object ^ ReadObject(System::Xml::XmlReader ^ reader);
public virtual object ReadObject (System.Xml.XmlReader reader);
public virtual object? ReadObject (System.Xml.XmlReader reader);
abstract member ReadObject : System.Xml.XmlReader -> obj
override this.ReadObject : System.Xml.XmlReader -> obj
Public Overridable Function ReadObject (reader As XmlReader) As Object

Parameters

reader
XmlReader

An XmlReader used to read the XML stream or document.

Returns

The deserialized object.

Applies to

ReadObject(XmlDictionaryReader, Boolean)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Reads the XML stream or document with an XmlDictionaryReader and returns the deserialized object; it also enables you to specify whether the serializer can read the data before attempting to read it.

public:
 abstract System::Object ^ ReadObject(System::Xml::XmlDictionaryReader ^ reader, bool verifyObjectName);
public abstract object ReadObject (System.Xml.XmlDictionaryReader reader, bool verifyObjectName);
public abstract object? ReadObject (System.Xml.XmlDictionaryReader reader, bool verifyObjectName);
abstract member ReadObject : System.Xml.XmlDictionaryReader * bool -> obj
Public MustOverride Function ReadObject (reader As XmlDictionaryReader, verifyObjectName As Boolean) As Object

Parameters

reader
XmlDictionaryReader

An XmlDictionaryReader used to read the XML document.

verifyObjectName
Boolean

true to check whether the enclosing XML element name and namespace correspond to the root name and root namespace; otherwise, false to skip the verification.

Returns

The deserialized object.

Remarks

The verifyObjectName parameter uses the same code as the IsStartObject method to determine whether the element is the start of the object.

Applies to

ReadObject(XmlReader, Boolean)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

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:
 virtual System::Object ^ ReadObject(System::Xml::XmlReader ^ reader, bool verifyObjectName);
public virtual object ReadObject (System.Xml.XmlReader reader, bool verifyObjectName);
public virtual object? ReadObject (System.Xml.XmlReader reader, bool verifyObjectName);
abstract member ReadObject : System.Xml.XmlReader * bool -> obj
override this.ReadObject : System.Xml.XmlReader * bool -> obj
Public Overridable Function ReadObject (reader As XmlReader, verifyObjectName As Boolean) As Object

Parameters

reader
XmlReader

An XmlReader used to read the XML document or stream.

verifyObjectName
Boolean

true to check whether the enclosing XML element name and namespace correspond to the root name and root namespace; false to skip the verification.

Returns

The deserialized object.

Remarks

The verifyObjectName parameter uses the same code as the IsStartObject method to determine whether the element is the start of the object.

Applies to