Поделиться через


PortTypeCollection.Item[] Свойство

Определение

Получает или задает объект PortType, определенный переданным параметром.

Перегрузки

Item[Int32]

Возвращает или задает значение PortType по указанному индексу (с нуля).

Item[String]

Получает объект PortType с указанным именем.

Item[Int32]

Исходный код:
ServiceDescription.cs
Исходный код:
ServiceDescription.cs
Исходный код:
ServiceDescription.cs

Возвращает или задает значение PortType по указанному индексу (с нуля).

public:
 property System::Web::Services::Description::PortType ^ default[int] { System::Web::Services::Description::PortType ^ get(int index); void set(int index, System::Web::Services::Description::PortType ^ value); };
public System.Web.Services.Description.PortType this[int index] { get; set; }
member this.Item(int) : System.Web.Services.Description.PortType with get, set
Default Public Property Item(index As Integer) As PortType

Параметры

index
Int32

Индекс (с нуля) объекта PortType, значение которого изменяется или возвращается.

Значение свойства

PortType.

Примеры

ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_CS.wsdl" );
PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes;
int noOfPortTypes = myServiceDescription->PortTypes->Count;
Console::WriteLine( "\nTotal number of PortTypes: {0}", myServiceDescription->PortTypes->Count );

// Get the first PortType in the collection.
PortType^ myNewPortType = myPortTypeCollection[ 0 ];
Console::WriteLine( "The PortType at index 0 is: {0}", myNewPortType->Name );
Console::WriteLine( "Removing the PortType {0}", myNewPortType->Name );

// Remove the PortType from the collection.
myPortTypeCollection->Remove( myNewPortType );

// Display the number of PortTypes.
Console::WriteLine( "\nTotal number of PortTypes after removing: {0}", myServiceDescription->PortTypes->Count );
Console::WriteLine( "Adding a PortType {0}", myNewPortType->Name );

// Add a new PortType from the collection.
myPortTypeCollection->Add( myNewPortType );

// Display the number of PortTypes after adding a port.
Console::WriteLine( "Total number of PortTypes after adding a new port: {0}", myServiceDescription->PortTypes->Count );
myServiceDescription->Write( "MathService_New.wsdl" );
ServiceDescription myServiceDescription =
   ServiceDescription.Read("MathService_CS.wsdl");
PortTypeCollection myPortTypeCollection =
   myServiceDescription.PortTypes;

int noOfPortTypes = myServiceDescription.PortTypes.Count;
Console.WriteLine("\nTotal number of PortTypes: "
   + myServiceDescription.PortTypes.Count);

// Get the first PortType in the collection.
PortType myNewPortType = myPortTypeCollection[0];
Console.WriteLine(
   "The PortType at index 0 is: " + myNewPortType.Name);
Console.WriteLine("Removing the PortType " + myNewPortType.Name);

// Remove the PortType from the collection.
myPortTypeCollection.Remove(myNewPortType);

// Display the number of PortTypes.
Console.WriteLine("\nTotal number of PortTypes after removing: "
   + myServiceDescription.PortTypes.Count);

Console.WriteLine("Adding a PortType " + myNewPortType.Name);

// Add a new PortType from the collection.
myPortTypeCollection.Add(myNewPortType);

// Display the number of PortTypes after adding a port.
Console.WriteLine("Total number of PortTypes after " +
   "adding a new port: " + myServiceDescription.PortTypes.Count);

myServiceDescription.Write("MathService_New.wsdl");
Dim myServiceDescription As ServiceDescription = _
   ServiceDescription.Read("MathService_VB.wsdl")
Dim myPortTypeCollection As PortTypeCollection = _
   myServiceDescription.PortTypes

Dim noOfPortTypes As Integer = myServiceDescription.PortTypes.Count
Console.WriteLine( _
   ControlChars.Newline & "Total number of PortTypes: " & _
   myServiceDescription.PortTypes.Count.ToString())

' Get the first PortType in the collection.
Dim myNewPortType As PortType = myPortTypeCollection(0)
Console.WriteLine( _
   "The PortType at index 0 is: " & myNewPortType.Name)
Console.WriteLine("Removing the PortType " & myNewPortType.Name)

' Remove the PortType from the collection.
myPortTypeCollection.Remove(myNewPortType)

' Display the number of PortTypes.
Console.WriteLine(ControlChars.Newline & _
   "Total number of PortTypes after removing: " & _
   myServiceDescription.PortTypes.Count.ToString())

Console.WriteLine("Adding a PortType " & myNewPortType.Name)

' Add a new PortType from the collection.
myPortTypeCollection.Add(myNewPortType)

' Display the number of PortTypes after adding a port.
Console.WriteLine( _
   "Total Number of PortTypes after adding a new port: " & _
   myServiceDescription.PortTypes.Count.ToString())

myServiceDescription.Write("MathService_New.wsdl")

Применяется к

Item[String]

Исходный код:
ServiceDescription.cs
Исходный код:
ServiceDescription.cs
Исходный код:
ServiceDescription.cs

Получает объект PortType с указанным именем.

public:
 property System::Web::Services::Description::PortType ^ default[System::String ^] { System::Web::Services::Description::PortType ^ get(System::String ^ name); };
public System.Web.Services.Description.PortType this[string name] { get; }
member this.Item(string) : System.Web.Services.Description.PortType
Default Public ReadOnly Property Item(name As String) As PortType

Параметры

name
String

Имя возвращенного объекта PortType.

Значение свойства

Имя параметра value.

Исключения

Параметр value не может быть явно приведен к типу PortType.

Примеры

ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_CS.wsdl" );
PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes;
int noOfPortTypes = myServiceDescription->PortTypes->Count;
Console::WriteLine( "\nTotal number of PortTypes: {0}", noOfPortTypes );
PortType^ myNewPortType = myPortTypeCollection[ "MathServiceSoap" ];
ServiceDescription myServiceDescription =
   ServiceDescription.Read("MathService_CS.wsdl");

PortTypeCollection myPortTypeCollection =
   myServiceDescription.PortTypes;
int noOfPortTypes = myServiceDescription.PortTypes.Count;
Console.WriteLine("\nTotal number of PortTypes: " + noOfPortTypes);

PortType myNewPortType = myPortTypeCollection["MathServiceSoap"];
Dim myServiceDescription As ServiceDescription = _
   ServiceDescription.Read("MathService_VB.wsdl")

Dim myPortTypeCollection As PortTypeCollection = _
   myServiceDescription.PortTypes
Dim noOfPortTypes As Integer = myServiceDescription.PortTypes.Count
Console.WriteLine(ControlChars.Newline & _
   "Total number of PortTypes: " & noOfPortTypes.ToString())

Dim myNewPortType As PortType = myPortTypeCollection("MathServiceSoap")

Применяется к