XmlReader.ReadContentAsAsync(Type, IXmlNamespaceResolver) XmlReader.ReadContentAsAsync(Type, IXmlNamespaceResolver) XmlReader.ReadContentAsAsync(Type, IXmlNamespaceResolver) XmlReader.ReadContentAsAsync(Type, IXmlNamespaceResolver) Method

定义

将内容作为指定类型的对象异步读取。Asynchronously reads the content as an object of the type specified.

public:
 virtual System::Threading::Tasks::Task<System::Object ^> ^ ReadContentAsAsync(Type ^ returnType, System::Xml::IXmlNamespaceResolver ^ namespaceResolver);
public virtual System.Threading.Tasks.Task<object> ReadContentAsAsync (Type returnType, System.Xml.IXmlNamespaceResolver namespaceResolver);
abstract member ReadContentAsAsync : Type * System.Xml.IXmlNamespaceResolver -> System.Threading.Tasks.Task<obj>
override this.ReadContentAsAsync : Type * System.Xml.IXmlNamespaceResolver -> System.Threading.Tasks.Task<obj>
Public Overridable Function ReadContentAsAsync (returnType As Type, namespaceResolver As IXmlNamespaceResolver) As Task(Of Object)

参数

returnType
Type Type Type Type

要返回的值的类型。The type of the value to be returned.

namespaceResolver
IXmlNamespaceResolver IXmlNamespaceResolver IXmlNamespaceResolver IXmlNamespaceResolver

一个 IXmlNamespaceResolver 对象,用于解析与类型转换有关的任何命名空间前缀。An IXmlNamespaceResolver object that is used to resolve any namespace prefixes related to type conversion.

返回

已转换为请求类型的串联文本内容或属性值。The concatenated text content or attribute value converted to the requested type.

异常

在上一次异步操作完成之前调用了 XmlReader 方法。An XmlReader method was called before a previous asynchronous operation finished. 在此情况下,会引发 InvalidOperationException 并显示消息“异步操作已在进行中。”In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

- 或 --or-

调用了 XmlReader 异步方法,但未将 Async 标志设置为 trueAn XmlReader asynchronous method was called without setting the Async flag to true. 在此情况下,将引发 InvalidOperationException 并显示消息“若要使用 Async 方法,请将 XmlReaderSettings.Async 设置为 True。”In this case, InvalidOperationException is thrown with the message "Set XmlReaderSettings.Async to true if you want to use Async Methods."

注解

这是异步版本ReadContentAs,具有相同功能。This is the asynchronous version of ReadContentAs, with the same functionality. 若要使用此方法,必须设置Async标记,用于trueTo use this method, you must set the Async flag to true.

适用于

另请参阅