本文整理匯總了C#中System.Web.Services.Description.ServiceDescriptionCollection類的典型用法代碼示例。如果您正苦於以下問題:C# ServiceDescriptionCollection類的具體用法?C# ServiceDescriptionCollection怎麽用?C# ServiceDescriptionCollection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ServiceDescriptionCollection類屬於System.Web.Services.Description命名空間,在下文中一共展示了ServiceDescriptionCollection類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
//引入命名空間
using System;
using System.Xml;
using System.Web.Services.Description;
class MyServiceDescriptionCollection
{
public static void Main()
{
try
{
// Get ServiceDescription objects.
ServiceDescription myServiceDescription1 =
ServiceDescription.Read("DataTypes_CS.wsdl");
ServiceDescription myServiceDescription2 =
ServiceDescription.Read("MathService_CS.wsdl");
// Set the names of the ServiceDescriptions.
myServiceDescription1.Name = "DataTypes";
myServiceDescription2.Name = "MathService";
// Create a ServiceDescriptionCollection.
ServiceDescriptionCollection myServiceDescriptionCollection =
new ServiceDescriptionCollection();
// Add the ServiceDescriptions to the collection.
myServiceDescriptionCollection.Add(myServiceDescription1);
myServiceDescriptionCollection.Add(myServiceDescription2);
// Display the elements of the collection using the indexer.
Console.WriteLine("Elements in the collection: ");
for(int i = 0; i < myServiceDescriptionCollection.Count; i++)
{
Console.WriteLine(myServiceDescriptionCollection[i].Name);
}
// Construct an XML qualified name.
XmlQualifiedName myXmlQualifiedName =
new XmlQualifiedName("MathServiceSoap", "http://tempuri2.org/");
// Get the Binding from the collection.
Binding myBinding =
myServiceDescriptionCollection.GetBinding(myXmlQualifiedName);
Console.WriteLine("Binding found in collection with name: " +
myBinding.ServiceDescription.Name);
}
catch(Exception e)
{
Console.WriteLine("The following exception was raised: {0}", e.Message);
}
}
}