本文整理汇总了C#中System.Web.Services.Discovery.DiscoveryReference类的典型用法代码示例。如果您正苦于以下问题:C# DiscoveryReference类的具体用法?C# DiscoveryReference怎么用?C# DiscoveryReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DiscoveryReference类属于System.Web.Services.Discovery命名空间,在下文中一共展示了DiscoveryReference类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.IO;
using System.Web.Services.Discovery;
using System.Net;
class MyDiscoveryDocumentClass
{
static void Main()
{
try {
DiscoveryDocument myDiscoveryDocument;
StreamReader myStreamReader =
new StreamReader("c:\\Inetpub\\wwwroot\\dataservice.disco");
FileStream myStream = new FileStream("c:\\MyDiscovery.disco",
FileMode.OpenOrCreate);
Console.WriteLine("Demonstrating DiscoveryReference class.");
// Read discovery file.
myDiscoveryDocument = DiscoveryDocument.Read(myStreamReader);
// Create a new instance of the DiscoveryReference class.
MyDiscoveryReferenceClass myDiscoveryReference;
myDiscoveryReference = new MyDiscoveryReferenceClass();
DiscoveryClientProtocol myDiscoveryClientProtocol =
new DiscoveryClientProtocol();
myDiscoveryClientProtocol.Credentials =
CredentialCache.DefaultCredentials;
// Set the client protocol.
myDiscoveryReference.ClientProtocol = myDiscoveryClientProtocol;
// Read the default file name.
Console.WriteLine("Default file name is: "
+ myDiscoveryReference.DefaultFilename);
// Write the document.
myDiscoveryReference.WriteDocument(myDiscoveryDocument,myStream);
// Read the document.
myDiscoveryReference.ReadDocument(myStream);
// Set the URL.
myDiscoveryReference.Url = "http://localhost/dataservice.disco";
Console.WriteLine("Url is: " + myDiscoveryReference.Url);
// Resolve the URL.
myDiscoveryReference.Resolve();
myStreamReader.Close();
myStream.Close();
}
catch (Exception e)
{
Console.WriteLine("Exception caught! - {0}", e.Message);
}
}
}
// Class derived from DiscoveryReference class and overriding it members.
class MyDiscoveryReferenceClass : DiscoveryReference
{
private string myDocumentUrl;
public override string DefaultFilename
{
get
{
return "dataservice.disco";
}
}
public override object ReadDocument(Stream stream)
{
return stream;
}
public new void Resolve()
{
try
{
DiscoveryDocument myDiscoveryRefDocument;
myDiscoveryRefDocument = base.ClientProtocol.Discover(Url);
}
catch (Exception e)
{
throw(e);
}
}
protected override void Resolve(string contentType, Stream stream) {}
public override string Url
{
get
{
return myDocumentUrl;
}
set
{
myDocumentUrl = value;
}
}
public override void WriteDocument(object document, System.IO.Stream stream)
{
DiscoveryDocument myDiscoveryDocument = (DiscoveryDocument)document;
myDiscoveryDocument.Write(stream);
}
}
开发者ID:.NET开发者,项目名称:System.Web.Services.Discovery,代码行数:111,代码来源:DiscoveryReference
注:本文中的System.Web.Services.Discovery.DiscoveryReference类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论