DiscoveryDocument.Read Method

Definition

Reads and returns a DiscoveryDocument from the passed object.

Overloads

Read(Stream)

Reads and returns a DiscoveryDocument from the passed Stream.

Read(TextReader)

Reads and returns a DiscoveryDocument from the passed TextReader.

Read(XmlReader)

Reads and returns a DiscoveryDocument from the passed XmlReader.

Read(Stream)

Reads and returns a DiscoveryDocument from the passed Stream.

public static System.Web.Services.Discovery.DiscoveryDocument Read (System.IO.Stream stream);

Parameters

stream
Stream

The Stream from which to read the DiscoveryDocument.

Returns

A DiscoveryDocument containing the contents of a discovery document from the passed Stream.

See also

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Read(TextReader)

Reads and returns a DiscoveryDocument from the passed TextReader.

public static System.Web.Services.Discovery.DiscoveryDocument Read (System.IO.TextReader reader);

Parameters

reader
TextReader

The TextReader from which to read the DiscoveryDocument.

Returns

A DiscoveryDocument containing the contents of a discovery document from the passed TextReader.

Examples

The following code example reads the discovery document from " http://localhost/example_Write2_cs.vsdisco " into a XmlTextReader.

// 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();

See also

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Read(XmlReader)

Reads and returns a DiscoveryDocument from the passed XmlReader.

public static System.Web.Services.Discovery.DiscoveryDocument Read (System.Xml.XmlReader xmlReader);

Parameters

xmlReader
XmlReader

The XmlReader from which to read the DiscoveryDocument.

Returns

A DiscoveryDocument containing the contents of a discovery document from the passed XmlReader.

Examples

The following code example reads in the contents of a discovery document, if the CanRead property is 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" );
}

See also

Applies to

.NET Framework 4.8.1 i druge verzije
Proizvod Verzije
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1