當前位置: 首頁>>代碼示例>>C#>>正文


C# Service.Extensions屬性代碼示例

本文整理匯總了C#中System.Web.Services.Description.Service.Extensions屬性的典型用法代碼示例。如果您正苦於以下問題:C# Service.Extensions屬性的具體用法?C# Service.Extensions怎麽用?C# Service.Extensions使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在System.Web.Services.Description.Service的用法示例。


在下文中一共展示了Service.Extensions屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: for

ServiceDescription myServiceDescription = 
   ServiceDescription.Read("MathService_CS.wsdl");
ServiceCollection myServiceCollection = 
   myServiceDescription.Services;

int noOfServices = myServiceCollection.Count;
Console.WriteLine("\nTotal number of services: " + noOfServices);

// Get a reference to the service.
Service myOldService = myServiceCollection[0];
Console.WriteLine("No. of Ports in the Service" + 
   myServiceCollection[0].Ports.Count);
Console.WriteLine("These are the ports in the service:");
for(int i = 0; i < myOldService.Ports.Count; i++)
   Console.WriteLine("Port name: " + myOldService.Ports[i].Name);
Console.WriteLine("Service name: " + myOldService.Name);

Service  myService = new Service();
myService.Name = "MathService";

// Add the ports to the newly created service.
for(int i = 0; i < myOldService.Ports.Count; i++)
{
   string PortName = myServiceCollection[0].Ports[i].Name;
   string BindingName = 
      myServiceCollection[0].Ports[i].Binding.Name;
   myService.Ports.Add(CreatePort(PortName, BindingName, 
      myServiceDescription.TargetNamespace));
}

Console.WriteLine("Newly created ports -");
for(int i = 0; i < myService.Ports.Count; i++)
   Console.WriteLine("Port Name: " + myOldService.Ports[i].Name);

// Add the extensions to the newly created service.
int noOfExtensions = myOldService.Extensions.Count;
Console.WriteLine("No. of extensions: " + noOfExtensions);
if (noOfExtensions > 0)
{
   for(int i = 0; i <myOldService.Ports.Count; i++)
      myService.Extensions.Add(
         myServiceCollection[0].Extensions[i]);
}

// Remove the service from the collection.
myServiceCollection.Remove(myOldService);

// Add the newly created service.
myServiceCollection.Add(myService);
myServiceDescription.Write("MathService_New.wsdl");
開發者ID:.NET開發者,項目名稱:System.Web.Services.Description,代碼行數:50,代碼來源:Service.Extensions


注:本文中的System.Web.Services.Description.Service.Extensions屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。