This documentation is archived and is not being maintained.

OperationFaultCollection::Contains Method

Returns a value indicating whether the specified OperationFault is a member of the OperationFaultCollection.

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

public:
bool Contains(
	OperationFault^ operationFaultMessage
)

Parameters

operationFaultMessage
Type: System.Web.Services.Description::OperationFault

The OperationFault for which to check collection membership.

Return Value

Type: System::Boolean
true if the operationFaultMessage parameter is a member of the OperationFaultCollection; otherwise, false.

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." );
}
PortTypeCollection * myPortTypeCollection = 
   myServiceDescription->PortTypes;
PortType * myPortType = myPortTypeCollection->Item[0];
OperationCollection * myOperationCollection = myPortType->Operations;
Operation * myOperation = myOperationCollection->Item[0];
OperationFaultCollection * myOperationFaultCollection =
   myOperation->Faults;

// Reverse the operation fault order.
if (myOperationFaultCollection->Count > 1) 
{
   OperationFault * myOperationFault =
      myOperationFaultCollection->Item[0];
   OperationFault* myOperationFaultArray[] = 
      new 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->Item[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->Item[j]);

   if (myOperationFaultCollection->Contains(myOperationFault) &&
      (myOperationFaultCollection->IndexOf(myOperationFault)
      == myOperationFaultCollection->Count-1)) 
      Console::WriteLine(S"Succeeded in reversing the operation faults.");
   else
      Console::WriteLine(S"Error while reversing the faults.");
}

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: