DiscoveryDocument.Read 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从所传递的对象中读取和返回一个 DiscoveryDocument。
重载
Read(Stream) |
从所传递的 DiscoveryDocument 中读取和返回一个 Stream。 |
Read(TextReader) |
从所传递的 DiscoveryDocument 中读取和返回一个 TextReader。 |
Read(XmlReader) |
从所传递的 DiscoveryDocument 中读取和返回一个 XmlReader。 |
Read(Stream)
从所传递的 DiscoveryDocument 中读取和返回一个 Stream。
public:
static System::Web::Services::Discovery::DiscoveryDocument ^ Read(System::IO::Stream ^ stream);
public static System.Web.Services.Discovery.DiscoveryDocument Read (System.IO.Stream stream);
static member Read : System.IO.Stream -> System.Web.Services.Discovery.DiscoveryDocument
Public Shared Function Read (stream As Stream) As DiscoveryDocument
参数
- stream
- Stream
将从其中读取 Stream 的 DiscoveryDocument。
返回
DiscoveryDocument,它包含所传递的 Stream 中的发现文档的内容。
另请参阅
适用于
Read(TextReader)
从所传递的 DiscoveryDocument 中读取和返回一个 TextReader。
public:
static System::Web::Services::Discovery::DiscoveryDocument ^ Read(System::IO::TextReader ^ reader);
public static System.Web.Services.Discovery.DiscoveryDocument Read (System.IO.TextReader reader);
static member Read : System.IO.TextReader -> System.Web.Services.Discovery.DiscoveryDocument
Public Shared Function Read (reader As TextReader) As DiscoveryDocument
参数
- reader
- TextReader
将从其中读取 TextReader 的 DiscoveryDocument。
返回
DiscoveryDocument,它包含所传递的 TextReader 中的发现文档的内容。
示例
下面的代码示例将发现文档从 “” http://localhost/example_Write2_cs.vsdisco
读入 XmlTextReader。
// Create a DiscoveryDocument.
DiscoveryDocument^ myDiscoveryDocument = gcnew DiscoveryDocument;
// Create an XmlTextReader with the sample file.
XmlTextReader^ myXmlTextReader = gcnew XmlTextReader(
"http://localhost/example_Write2_cs.disco" );
// Read the given XmlTextReader.
myDiscoveryDocument = DiscoveryDocument::Read( myXmlTextReader );
FileStream^ myFileStream = gcnew FileStream(
"log.txt",FileMode::OpenOrCreate,FileAccess::Write );
StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream );
XmlTextWriter^ myXmlTextWriter = gcnew XmlTextWriter( myStreamWriter );
myDiscoveryDocument->Write( myXmlTextWriter );
myXmlTextWriter->Flush();
myXmlTextWriter->Close();
// Display the contents of the DiscoveryDocument on the console.
FileStream^ myFileStream1 = gcnew FileStream(
"log.txt",FileMode::OpenOrCreate,FileAccess::Read );
StreamReader^ myStreamReader = gcnew StreamReader( myFileStream1 );
// Set the file pointer to the beginning.
myStreamReader->BaseStream->Seek( 0, SeekOrigin::Begin );
Console::WriteLine( "The contents of the DiscoveryDocument are: " );
while ( myStreamReader->Peek() > -1 )
{
Console::WriteLine( myStreamReader->ReadLine() );
}
myStreamReader->Close();
// Create a DiscoveryDocument.
DiscoveryDocument myDiscoveryDocument = new DiscoveryDocument();
// Create an XmlTextReader with the sample file.
XmlTextReader myXmlTextReader = new
XmlTextReader( "http://localhost/example_Write2_cs.disco" );
// Read the given XmlTextReader.
myDiscoveryDocument = DiscoveryDocument.Read( myXmlTextReader );
FileStream myFileStream = new
FileStream( "log.txt", FileMode.OpenOrCreate, FileAccess.Write );
StreamWriter myStreamWriter = new StreamWriter( myFileStream );
XmlTextWriter myXmlTextWriter = new XmlTextWriter( myStreamWriter );
myDiscoveryDocument.Write( myXmlTextWriter );
myXmlTextWriter.Flush();
myXmlTextWriter.Close();
// Display the contents of the DiscoveryDocument on the console.
FileStream myFileStream1 = new
FileStream( "log.txt", FileMode.OpenOrCreate, FileAccess.Read );
StreamReader myStreamReader = new StreamReader( myFileStream1 );
// Set the file pointer to the beginning.
myStreamReader.BaseStream.Seek(0, SeekOrigin.Begin);
Console.WriteLine( "The contents of the DiscoveryDocument are:" );
while ( myStreamReader.Peek() > -1 )
{
Console.WriteLine( myStreamReader.ReadLine() );
}
myStreamReader.Close();
' Create a DiscoveryDocument.
Dim myDiscoveryDocument As New DiscoveryDocument()
' Create an XmlTextReader with the sample file.
Dim myXmlTextReader As _
New XmlTextReader("http://localhost/example_Write2_vb.disco")
' Read the given XmlTextReader.
myDiscoveryDocument = DiscoveryDocument.Read(myXmlTextReader)
Dim myFileStream As _
New FileStream("log.txt", FileMode.OpenOrCreate, FileAccess.Write)
Dim myStreamWriter As New StreamWriter(myFileStream)
Dim myXmlTextWriter As New XmlTextWriter(myStreamWriter)
myDiscoveryDocument.Write(myXmlTextWriter)
myXmlTextWriter.Flush()
myXmlTextWriter.Close()
' Display the contents of the DiscoveryDocument on the console.
Dim myFileStream1 As New FileStream( _
"log.txt", FileMode.OpenOrCreate, FileAccess.Read)
Dim myStreamReader As New StreamReader(myFileStream1)
' Set the file pointer to the beginning.
myStreamReader.BaseStream.Seek(0, SeekOrigin.Begin)
Console.WriteLine("The contents of the DiscoveryDocument are: ")
While myStreamReader.Peek() > - 1
Console.WriteLine(myStreamReader.ReadLine())
End While
myStreamReader.Close()
另请参阅
适用于
Read(XmlReader)
从所传递的 DiscoveryDocument 中读取和返回一个 XmlReader。
public:
static System::Web::Services::Discovery::DiscoveryDocument ^ Read(System::Xml::XmlReader ^ xmlReader);
public static System.Web.Services.Discovery.DiscoveryDocument Read (System.Xml.XmlReader xmlReader);
static member Read : System.Xml.XmlReader -> System.Web.Services.Discovery.DiscoveryDocument
Public Shared Function Read (xmlReader As XmlReader) As DiscoveryDocument
参数
- xmlReader
- XmlReader
将从其中读取 XmlReader 的 DiscoveryDocument。
返回
DiscoveryDocument,它包含所传递的 XmlReader 中的发现文档的内容。
示例
如果 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