This documentation is archived and is not being maintained.
PortTypeCollection::Contains Method
Visual Studio 2008
Returns a value indicating whether the specified PortType is a member of the PortTypeCollection.
Assembly: System.Web.Services (in System.Web.Services.dll)
Parameters
- portType
- Type: System.Web.Services.Description::PortType
The PortType for which to check for collection membership.
Return Value
Type: System::Booleantrue if the portType parameter is a member of the PortTypeCollection; otherwise, false.
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 ); // Display the number of portTypes after adding a port. Console::WriteLine( "Total number of PortTypes after adding a new port: {0}", myServiceDescription->PortTypes->Count ); bContains = myPortTypeCollection->Contains( myNewPortType ); Console::WriteLine( "Port Type'{0}' exists: {1}", myNewPortType->Name, bContains ); myServiceDescription->Write( "MathService_New.wsdl" );
ServiceDescription* myServiceDescription =
ServiceDescription::Read(S"MathService_CS.wsdl");
PortTypeCollection* myPortTypeCollection =
myServiceDescription->PortTypes;
int noOfPortTypes = myServiceDescription->PortTypes->Count;
Console::WriteLine(S"\nTotal number of PortTypes: {0}", __box(noOfPortTypes));
PortType* myNewPortType = myPortTypeCollection->Item[S"MathServiceSoap"];
// Get the index in the collection.
int index = myPortTypeCollection->IndexOf(myNewPortType);
Console::WriteLine(S"Removing the PortType named {0}", myNewPortType->Name);
// Remove the PortType from the collection.
myPortTypeCollection->Remove(myNewPortType);
noOfPortTypes = myServiceDescription->PortTypes->Count;
Console::WriteLine(S"\nTotal number of PortTypes: {0}", __box(noOfPortTypes));
// Check whether the PortType exists in the collection.
bool bContains = myPortTypeCollection->Contains(myNewPortType);
Console::WriteLine(S"Port Type'{0}' exists: {1}", myNewPortType->Name, __box(bContains));
Console::WriteLine(S"Adding the PortType");
// Insert a new portType at the index location.
myPortTypeCollection->Insert(index, myNewPortType);
// Display the number of portTypes after adding a port.
Console::WriteLine(S"Total number of PortTypes after adding a new port: {0}", __box(myServiceDescription->PortTypes->Count));
bContains = myPortTypeCollection->Contains(myNewPortType);
Console::WriteLine(S"Port Type'{0}' exists: {1}", myNewPortType->Name, __box(bContains));
myServiceDescription->Write(S"MathService_New.wsdl");
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.
Show: