FaultBindingCollection::Insert Method
Adds the specified FaultBinding to the FaultBindingCollection 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 bindingOperationFault parameter.
- bindingOperationFault
- Type: System.Web.Services.Description::FaultBinding
The FaultBinding 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 FaultBindingCollection.
The elements after the insertion point move down to accommodate the new element.
The following example demonstrates a typical use of the Insert method.
BindingCollection^ myBindingCollection = myServiceDescription->Bindings; Binding^ myBinding = myBindingCollection[ 0 ]; OperationBindingCollection^ myOperationBindingCollection = myBinding->Operations; OperationBinding^ myOperationBinding = myOperationBindingCollection[ 0 ]; FaultBindingCollection^ myFaultBindingCollection = myOperationBinding->Faults; // Reverse the fault bindings order. if ( myFaultBindingCollection->Count > 1 ) { FaultBinding^ myFaultBinding = myFaultBindingCollection[ 0 ]; array<FaultBinding^>^myFaultBindingArray = gcnew array<FaultBinding^>(myFaultBindingCollection->Count); // Copy the fault bindings to a temporary array. myFaultBindingCollection->CopyTo( myFaultBindingArray, 0 ); // Remove all the fault binding instances in the fault binding collection. for ( int i = 0; i < myFaultBindingArray->Length; i++ ) myFaultBindingCollection->Remove( myFaultBindingArray[ i ] ); // Insert the fault binding instance in the reverse order. for ( int i = 0,j = (myFaultBindingArray->Length - 1); i < myFaultBindingArray->Length; i++,j-- ) myFaultBindingCollection->Insert( i, myFaultBindingArray[ j ] ); // Check if the first element in the collection before the reversal is now the last element. if ( myFaultBindingCollection->Contains( myFaultBinding ) && myFaultBindingCollection->IndexOf( myFaultBinding ) == (myFaultBindingCollection->Count - 1) ) // Display the WSDL generated to the console. myServiceDescription->Write( Console::Out ); else Console::WriteLine( "Error while reversing" ); }
BindingCollection * myBindingCollection = myServiceDescription->Bindings;
Binding * myBinding = myBindingCollection->Item[0];
OperationBindingCollection * myOperationBindingCollection = myBinding->Operations;
OperationBinding * myOperationBinding = myOperationBindingCollection->Item[0];
FaultBindingCollection * myFaultBindingCollection = myOperationBinding->Faults;
// Reverse the fault bindings order.
if (myFaultBindingCollection->Count > 1)
{
FaultBinding * myFaultBinding = myFaultBindingCollection->Item[0];
FaultBinding* myFaultBindingArray[] = new FaultBinding*[myFaultBindingCollection->Count];
// Copy the fault bindings to a temporary array.
myFaultBindingCollection->CopyTo(myFaultBindingArray, 0);
// Remove all the fault binding instances in the fault binding collection.
for (int i = 0; i < myFaultBindingArray->Length; i++)
myFaultBindingCollection->Remove(myFaultBindingArray->Item[i]);
// Insert the fault binding instance in the reverse order.
for (int i = 0, j = (myFaultBindingArray->Length - 1); i < myFaultBindingArray->Length; i++, j--)
myFaultBindingCollection->Insert(i, myFaultBindingArray->Item[j]);
// Check if the first element in the collection before the reversal is now the last element.
if (myFaultBindingCollection->Contains(myFaultBinding) &&
myFaultBindingCollection->IndexOf(myFaultBinding) == (myFaultBindingCollection->Count - 1))
// Display the WSDL generated to the console.
myServiceDescription->Write(Console::Out);
else
Console::WriteLine(S"Error while reversing");
}
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.