共用方式為


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

XmlReader,要測試是否能還原序列化為 DiscoveryDocument

傳回

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

適用於

另請參閱