DiscoveryDocument.CanRead(XmlReader) 方法

定义

返回一个值,该值指示传递的 XmlReader 是否可以反序列化为 DiscoveryDocument

public:
 static bool CanRead(System::Xml::XmlReader ^ xmlReader);
public static bool CanRead (System.Xml.XmlReader xmlReader);
static member CanRead : System.Xml.XmlReader -> bool
Public Shared Function CanRead (xmlReader As XmlReader) As Boolean

参数

xmlReader
XmlReader

被测试是否可以将其反序列化为 XmlReaderDiscoveryDocument

返回

Boolean

如果 XmlReader 可以反序列化为 DiscoveryDocument,则为 true;否则为 false

示例

下面的代码示例在发现文档的内容(如果 CanRead 属性为 true)中读取。

// Check whether the given XmlTextReader is readable.
if ( DiscoveryDocument::CanRead( myXmlTextReader ) == true )
      
// Read the given XmlTextReader.
myDiscoveryDocument = DiscoveryDocument::Read( myXmlTextReader );
else
      Console::WriteLine( "The supplied file is not readable" );
// Check whether the given XmlTextReader is readable.
if( DiscoveryDocument.CanRead( myXmlTextReader ) == true )
{
   // Read the given XmlTextReader.
   myDiscoveryDocument = DiscoveryDocument.Read( myXmlTextReader );
}
else
{
   Console.WriteLine( "The supplied file is not readable" );
}
' Check whether the given XmlTextReader is readable.
If DiscoveryDocument.CanRead(myXmlTextReader) = True Then
   ' Read the given XmlTextReader.
   myDiscoveryDocument = DiscoveryDocument.Read(myXmlTextReader)
Else
   Console.WriteLine("The supplied file is not readable")
End If

适用于

另请参阅