XmlObjectSerializer.ReadObject 方法

定义

读取一个 XML 文档或文档流,并返回反序列化的对象。Reads an XML document or document stream and returns the deserialized object.

重载

ReadObject(Stream)

使用 Stream 读取 XML 流或文档,然后返回反序列化的对象。Reads the XML stream or document with a Stream and returns the deserialized object.

ReadObject(XmlDictionaryReader)

使用 XmlDictionaryReader 读取 XML 文档或流,然后返回反序列化的对象。Reads the XML document or stream with an XmlDictionaryReader and returns the deserialized object.

ReadObject(XmlReader)

使用 XmlReader 读取 XML 文档或流,然后返回反序列化的对象。Reads the XML document or stream with an XmlReader and returns the deserialized object.

ReadObject(XmlDictionaryReader, Boolean)

使用 XmlDictionaryReader 读取 XML 流或文档并返回反序列化的对象;它还可用于在序列化器尝试读取数据之前指定它是否可以读取数据。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)

使用 XmlReader 读取 XML 文档或流并返回反序列化的对象;它还可用于在序列化器尝试读取数据之前指定它是否可以读取数据。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)

使用 Stream 读取 XML 流或文档,然后返回反序列化的对象。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

参数

stream
Stream

用于读取 XML 流或文档的 StreamA Stream used to read the XML stream or document.

返回

Object

已反序列化的对象。The deserialized object.

注解

此方法为虚拟方法,并且有一个默认实现,该实现创建一个字典读取器以读取基础流并将其反序列化。This method is a virtual method, and has a default implementation that creates a dictionary reader to read the underlying stream and deserialize it. 默认实现假设流为文本或 XML。The default implementation assumes the stream is text or XML.

适用于

ReadObject(XmlDictionaryReader)

使用 XmlDictionaryReader 读取 XML 文档或流,然后返回反序列化的对象。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

参数

reader
XmlDictionaryReader

一个用于读取 XML 文档的 XmlDictionaryReaderAn XmlDictionaryReader used to read the XML document.

返回

Object

已反序列化的对象。The deserialized object.

注解

此方法为虚拟方法,并且有一个默认实现,该实现创建一个字典读取器以读取基础流并将其反序列化。This method is a virtual method, and has a default implementation that creates a dictionary reader to read the underlying stream and deserialize it. 默认实现假设流为文本或 XML。The default implementation assumes the stream is text or XML.

适用于

ReadObject(XmlReader)

使用 XmlReader 读取 XML 文档或流,然后返回反序列化的对象。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

参数

reader
XmlReader

一个用于读取 XML 流或文档的 XmlReaderAn XmlReader used to read the XML stream or document.

返回

Object

已反序列化的对象。The deserialized object.

适用于

ReadObject(XmlDictionaryReader, Boolean)

使用 XmlDictionaryReader 读取 XML 流或文档并返回反序列化的对象;它还可用于在序列化器尝试读取数据之前指定它是否可以读取数据。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

参数

reader
XmlDictionaryReader

一个用于读取 XML 文档的 XmlDictionaryReaderAn XmlDictionaryReader used to read the XML document.

verifyObjectName
Boolean

如果为 true,则检查外层 XML 元素名和命名空间是否对应于根名称和根命名空间;否则为 false 以跳过验证。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.

返回

Object

已反序列化的对象。The deserialized object.

注解

verifyObjectName 参数使用与 IsStartObject 方法相同的代码来确定该元素是否是对象的开始位置。The verifyObjectName parameter uses the same code as the IsStartObject method to determine whether the element is the start of the object.

适用于

ReadObject(XmlReader, Boolean)

使用 XmlReader 读取 XML 文档或流并返回反序列化的对象;它还可用于在序列化器尝试读取数据之前指定它是否可以读取数据。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

参数

reader
XmlReader

用于读取 XML 文档或流的 XmlReaderAn XmlReader used to read the XML document or stream.

verifyObjectName
Boolean

如果为 true,则检查外层 XML 元素名和命名空间是否对应于根名称和根命名空间;若为 false 则跳过验证。true to check whether the enclosing XML element name and namespace correspond to the root name and root namespace; false to skip the verification.

返回

Object

已反序列化的对象。The deserialized object.

注解

verifyObjectName 参数使用与 IsStartObject 方法相同的代码来确定该元素是否是对象的开始位置。The verifyObjectName parameter uses the same code as the IsStartObject method to determine whether the element is the start of the object.

适用于