Freigeben über


PortTypeCollection.Insert-Methode

Fügt der PortTypeCollection den angegebenen PortType am angegebenen nullbasierten Index hinzu.

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)

Syntax

'Declaration
Public Sub Insert ( _
    index As Integer, _
    portType As PortType _
)
'Usage
Dim instance As PortTypeCollection
Dim index As Integer
Dim portType As PortType

instance.Insert(index, portType)
public void Insert (
    int index,
    PortType portType
)
public:
void Insert (
    int index, 
    PortType^ portType
)
public void Insert (
    int index, 
    PortType portType
)
public function Insert (
    index : int, 
    portType : PortType
)

Parameter

  • index
    Der nullbasierte Index, an dem der portType-Parameter eingefügt werden soll.
  • portType
    Der der Auflistung hinzuzufügende PortType.

Ausnahmen

Ausnahmetyp Bedingung

IndexOutOfRangeException

Der index-Parameter ist kleiner als 0.

– oder –

Der index-Parameter ist größer als Count.

Hinweise

Wenn die Anzahl der Elemente in der Auflistung bereits der Kapazität der Auflistung entspricht, wird diese verdoppelt, indem das interne Array vor dem Einfügen des neuen Elements automatisch neu reserviert wird.

Wenn der Wert des index-Parameters gleich Count ist, wird die angegebene PortType-Instanz am Ende der PortTypeCollection hinzugefügt.

Die Elemente nach der Einfügemarke werden nach unten verschoben, um das neue Element aufnehmen zu können.

Beispiel

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")
' Get the index in the collection.
Dim index As Integer = myPortTypeCollection.IndexOf(myNewPortType)
Console.WriteLine("Removing the PortType named " & _
   myNewPortType.Name)

' Remove the PortType from the collection.
myPortTypeCollection.Remove(myNewPortType)
noOfPortTypes = myServiceDescription.PortTypes.Count
Console.WriteLine(ControlChars.Newline & _
   "Total number of PortTypes: " & noOfPortTypes.ToString())

' Check whether the PortType exists in the collection.
Dim bContains As Boolean = myPortTypeCollection.Contains(myNewPortType)
Console.WriteLine("Port Type'" & myNewPortType.Name & _
   "' exists: " & bContains.ToString())

Console.WriteLine("Adding the 'PortType'")
' Insert a new portType at the index location.
myPortTypeCollection.Insert(index, myNewPortType)
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"];

// Get the index in the collection.
int index = myPortTypeCollection.IndexOf(myNewPortType);
Console.WriteLine("Removing the PortType named " 
   + myNewPortType.Name);

// Remove the PortType from the collection.
myPortTypeCollection.Remove(myNewPortType);
noOfPortTypes = myServiceDescription.PortTypes.Count;
Console.WriteLine("\nTotal number of PortTypes: " 
   + noOfPortTypes);

// Check whether the PortType exists in the collection.
bool bContains = myPortTypeCollection.Contains(myNewPortType);
Console.WriteLine("Port Type'" + myNewPortType.Name + "' exists: " 
   + bContains );

Console.WriteLine("Adding the PortType");
// Insert a new portType at the index location.
myPortTypeCollection.Insert(index, myNewPortType);
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" ];

// Get the index in the collection.
int index = myPortTypeCollection->IndexOf( myNewPortType );

Console::WriteLine( "Removing the PortType named {0}", myNewPortType->Name );

// Remove the PortType from the collection.
myPortTypeCollection->Remove( myNewPortType );
noOfPortTypes = myServiceDescription->PortTypes->Count;
Console::WriteLine( "\nTotal number of PortTypes: {0}", noOfPortTypes );

// Check whether the PortType exists in the collection.
bool bContains = myPortTypeCollection->Contains( myNewPortType );
Console::WriteLine( "Port Type'{0}' exists: {1}", myNewPortType->Name, bContains );
Console::WriteLine( "Adding the PortType" );

// Insert a new portType at the index location.
myPortTypeCollection->Insert( index, myNewPortType );
ServiceDescription myServiceDescription = ServiceDescription.Read(
    "MathService_JSL.wsdl");

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

PortType myNewPortType = 
    myPortTypeCollection.get_Item("MathServiceSoap");

// Get the index in the collection.
int index = myPortTypeCollection.IndexOf(myNewPortType);
Console.WriteLine("Removing the PortType named " 
    + myNewPortType.get_Name());

// Remove the PortType from the collection.
myPortTypeCollection.Remove(myNewPortType);
noOfPortTypes = myServiceDescription.get_PortTypes().get_Count();
Console.WriteLine("\nTotal number of PortTypes: " + noOfPortTypes);

// Check whether the PortType exists in the collection.
boolean bContains = myPortTypeCollection.Contains(myNewPortType);
Console.WriteLine("Port Type'" + myNewPortType.get_Name() 
    + "' exists: " + bContains);

Console.WriteLine("Adding the PortType");

// Insert a new portType at the index location.
myPortTypeCollection.Insert(index, myNewPortType);

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

PortTypeCollection-Klasse
PortTypeCollection-Member
System.Web.Services.Description-Namespace