PortCollection クラス
Port クラスのインスタンスのコレクションを表します。このクラスは継承できません。
この型のすべてのメンバの一覧については、PortCollection メンバ を参照してください。
System.Object
System.Collections.CollectionBase
System.Web.Services.Description.ServiceDescriptionBaseCollection
System.Web.Services.Description.PortCollection
NotInheritable Public Class PortCollection
Inherits ServiceDescriptionBaseCollection
[C#]
public sealed class PortCollection :
ServiceDescriptionBaseCollection
[C++]
public __gc __sealed class PortCollection : public
ServiceDescriptionBaseCollection
[JScript]
public class PortCollection extends
ServiceDescriptionBaseCollection
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
使用例
Dim myService As Service
Dim myPortCollection As PortCollection
Dim myServiceDescription As ServiceDescription = _
ServiceDescription.Read("MathServiceItem_vb.wsdl")
Console.WriteLine("Total number of services : " & _
myServiceDescription.Services.Count.ToString)
Dim i As Integer
For i = 0 to myServiceDescription.Services.Count - 1
myService = myServiceDescription.Services(i)
Console.WriteLine("Name : " & myService.Name)
myPortCollection = myService.Ports
' Create an array of ports.
Console.WriteLine(ControlChars.NewLine & "Port collection :")
Dim i1 As Integer
For i1 = 0 to myService.Ports.Count - 1
Console.WriteLine("Port[" & i1.ToString & "] : " & _
myPortCollection(i1).Name)
Next
Dim strPort As String = myPortCollection(0).Name
Dim myPort As Port = myPortCollection(strPort)
Console.WriteLine(ControlChars.NewLine & _
"Index of Port[" & strPort & "] : " & _
myPortCollection.IndexOf(myPort).ToString)
Dim myPortTestRemove As Port = myPortCollection(0)
Console.WriteLine(ControlChars.NewLine & _
"Total number of ports before removing " & _
"a port '" & myPortTestRemove.Name & "' is : " & _
myService.Ports.Count.ToString)
myPortCollection.Remove(myPortTestRemove)
Console.WriteLine("Total number of ports after removing " & _
"a port '" & myPortTestRemove.Name & "' is : " & _
myService.Ports.Count.ToString)
' Create the WSDL file.
myPortCollection.Insert(0, myPortTestRemove)
myServiceDescription.Write("MathServiceItemNew_vb.wsdl")
Next
[C#]
Service myService;
PortCollection myPortCollection;
ServiceDescription myServiceDescription =
ServiceDescription.Read("MathServiceItem_cs.wsdl");
Console.WriteLine("Total number of services : "
+ myServiceDescription.Services.Count);
for(int i=0; i < myServiceDescription.Services.Count; ++i)
{
myService = myServiceDescription.Services[i];
Console.WriteLine("Name : " + myService.Name);
myPortCollection = myService.Ports;
// Create an array of ports.
Console.WriteLine("\nPort collection :");
for(int i1=0 ; i1 < myService.Ports.Count ; ++i1)
{
Console.WriteLine("Port[" + i1+"] : " +
myPortCollection[i1].Name);
}
string strPort = myPortCollection[0].Name;
Port myPort = myPortCollection[strPort];
Console.WriteLine("\nIndex of Port[" + strPort + "] : " +
myPortCollection.IndexOf(myPort));
Port myPortTestRemove = myPortCollection[0];
Console.WriteLine("\nTotal number of ports before removing "
+ "a port '" + myPortTestRemove.Name +"' is : "
+ myService.Ports.Count);
myPortCollection.Remove(myPortTestRemove);
Console.WriteLine("Total number of ports after removing "
+ "a port '" + myPortTestRemove.Name +"' is : "
+ myService.Ports.Count);
// Create the WSDL file.
myPortCollection.Insert(0, myPortTestRemove);
myServiceDescription.Write("MathServiceItemNew_cs.wsdl");
[C++]
Service* myService;
PortCollection* myPortCollection;
ServiceDescription* myServiceDescription =
ServiceDescription::Read(S"MathServiceItem_cs.wsdl");
Console::WriteLine(S"Total number of services : {0}", __box(myServiceDescription->Services->Count));
for(int i=0; i < myServiceDescription->Services->Count; ++i)
{
myService = myServiceDescription->Services->Item[i];
Console::WriteLine(S"Name : {0}", myService->Name);
myPortCollection = myService->Ports;
// Create an array of ports.
Console::WriteLine(S"\nPort collection :");
for(int i1=0 ; i1 < myService->Ports->Count ; ++i1)
{
Console::WriteLine(S"Port[{0}] : {1}", __box(i1), myPortCollection->Item[i1]->Name);
}
String* strPort = myPortCollection->Item[0]->Name;
Port* myPort = myPortCollection->Item[strPort];
Console::WriteLine(S"\nIndex of Port[{0}] : {1}", strPort, __box(myPortCollection->IndexOf(myPort)));
Port* myPortTestRemove = myPortCollection->Item[0];
Console::WriteLine(S"\nTotal number of ports before removing a port '{0}' is : {1}", myPortTestRemove->Name, __box(myService->Ports->Count));
myPortCollection->Remove(myPortTestRemove);
Console::WriteLine(S"Total number of ports after removing a port '{0}' is : {1}", myPortTestRemove->Name, __box(myService->Ports->Count));
// Create the WSDL file.
myPortCollection->Insert(0, myPortTestRemove);
myServiceDescription->Write(S"MathServiceItemNew_cs.wsdl");
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Web.Services.Description
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System.Web.Services (System.Web.Services.dll 内)