PortTypeCollection.Contains Method

Returns a value indicating whether the specified PortType is a member of the PortTypeCollection.

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

public:
bool Contains (
	PortType^ portType
)
public boolean Contains (
	PortType portType
)
public function Contains (
	portType : PortType
) : boolean
Not applicable.

Parameters

portType

The PortType for which to check for collection membership.

Return Value

true 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(
    "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);

// Display the number of portTypes after adding a port.
Console.WriteLine("Total number of PortTypes after " 
    + "adding a new port: " 
    + myServiceDescription.get_PortTypes().get_Count());

bContains = myPortTypeCollection.Contains(myNewPortType);
Console.WriteLine("Port Type'" + myNewPortType.get_Name() 
    + "' exists: " + bContains);
myServiceDescription.Write("MathService_New.wsdl");

Windows 98, Windows Server 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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: