OperationFaultCollection::Insert Method (Int32, OperationFault^)
.NET Framework (current version)
Adds the specified OperationFault to the OperationFaultCollection at the specified zero-based index.
Assembly: System.Web.Services (in System.Web.Services.dll)
Parameters
- index
-
Type:
System::Int32
The zero-based index at which to insert the operationFaultMessage parameter.
- operationFaultMessage
-
Type:
System.Web.Services.Description::OperationFault^
The OperationFault to add to the collection.
If the number of items in the collection already equals the collection's capacity, the capacity is doubled by automatically reallocating the internal array before the new element is inserted.
If the index parameter is equal to Count, the bindingOperationFault parameter is added to the end of the collection.
The elements after the insertion point move down to accommodate the new element.
PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; PortType^ myPortType = myPortTypeCollection[ 0 ]; OperationCollection^ myOperationCollection = myPortType->Operations; Operation^ myOperation = myOperationCollection[ 0 ]; OperationFaultCollection^ myOperationFaultCollection = myOperation->Faults; // Reverse the operation fault order. if ( myOperationFaultCollection->Count > 1 ) { OperationFault^ myOperationFault = myOperationFaultCollection[ 0 ]; array<OperationFault^>^myOperationFaultArray = gcnew array<OperationFault^>(myOperationFaultCollection->Count); // Copy the operation fault to a temporary array. myOperationFaultCollection->CopyTo( myOperationFaultArray, 0 ); // Remove all the operation faults from the collection. for ( int i = 0; i < myOperationFaultArray->Length; i++ ) myOperationFaultCollection->Remove( myOperationFaultArray[ i ] ); // Insert the operation faults in the reverse order. for ( int i = 0,j = (myOperationFaultArray->Length - 1); i < myOperationFaultArray->Length; i++,j-- ) myOperationFaultCollection->Insert( i, myOperationFaultArray[ j ] ); if ( myOperationFaultCollection->Contains( myOperationFault ) && (myOperationFaultCollection->IndexOf( myOperationFault ) == myOperationFaultCollection->Count - 1) ) Console::WriteLine( "Succeeded in reversing the operation faults." ); else Console::WriteLine( "Error while reversing the faults." ); }
.NET Framework
Available since 1.1
Available since 1.1
Show: