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

定义

将元素内容作为请求类型异步读取。Asynchronously reads the element content as the requested type.

public:
 virtual System::Threading::Tasks::Task<System::Object ^> ^ ReadElementContentAsAsync(Type ^ returnType, System::Xml::IXmlNamespaceResolver ^ namespaceResolver);
public virtual System.Threading.Tasks.Task<object> ReadElementContentAsAsync (Type returnType, System.Xml.IXmlNamespaceResolver namespaceResolver);
abstract member ReadElementContentAsAsync : Type * System.Xml.IXmlNamespaceResolver -> System.Threading.Tasks.Task<obj>
override this.ReadElementContentAsAsync : Type * System.Xml.IXmlNamespaceResolver -> System.Threading.Tasks.Task<obj>
Public Overridable Function ReadElementContentAsAsync (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 element content converted to the requested typed object.

异常

在上一次异步操作完成之前调用了 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."

注解

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

适用于

另请参阅