MessagePartCollection.Remove(MessagePart) Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Quita la primera aparición del objeto MessagePart especificado de MessagePartCollection.
public:
void Remove(System::Web::Services::Description::MessagePart ^ messagePart);
public void Remove (System.Web.Services.Description.MessagePart messagePart);
member this.Remove : System.Web.Services.Description.MessagePart -> unit
Public Sub Remove (messagePart As MessagePart)
Parámetros
- messagePart
- MessagePart
MessagePart que se va a quitar de la colección.
Ejemplos
En el siguiente ejemplo se muestra el uso del método Remove
.
Console::WriteLine( "Checking if message is AddHttpPostOut..." );
Message^ myMessage = myServiceDescription->Messages[ "AddHttpPostOut" ];
if ( myMessageCollection->Contains( myMessage ) )
{
// Get the mssage part collection.
MessagePartCollection^ myMessagePartCollection = myMessage->Parts;
// Get the part named Body.
MessagePart^ myMessagePart = myMessage->Parts[ "Body" ];
if ( myMessagePartCollection->Contains( myMessagePart ) )
{
// Get the part named Body.
Console::WriteLine( "Index of Body in MessagePart collection = {0}", myMessagePartCollection->IndexOf( myMessagePart ) );
Console::WriteLine( "Deleting Body from MessagePart collection..." );
myMessagePartCollection->Remove( myMessagePart );
if ( myMessagePartCollection->IndexOf( myMessagePart ) == -1 )
Console::WriteLine( "from the message AddHttpPostOut." );
}
}
Console.WriteLine("Checking if message is AddHttpPostOut...");
Message myMessage = myServiceDescription.Messages["AddHttpPostOut"];
if (myMessageCollection.Contains(myMessage))
{
// Get the message part collection.
MessagePartCollection myMessagePartCollection = myMessage.Parts;
// Get the part named Body.
MessagePart myMessagePart = myMessage.Parts["Body"];
if (myMessagePartCollection.Contains(myMessagePart))
{
// Get the index of the part named Body.
Console.WriteLine("Index of Body in MessagePart collection = " +
myMessagePartCollection.IndexOf(myMessagePart));
Console.WriteLine("Deleting Body from MessagePart collection...");
myMessagePartCollection.Remove(myMessagePart);
if(myMessagePartCollection.IndexOf(myMessagePart)== -1)
{
Console.WriteLine("MessagePart Body successfully deleted " +
"from the message AddHttpPostOut.");
}
}
}
Console.WriteLine("Checking if message is AddHttpPostOut...")
Dim myMessage As Message = myServiceDescription.Messages("AddHttpPostOut")
If myMessageCollection.Contains(myMessage) Then
' Get the message part collection.
Dim myMessagePartCollection As MessagePartCollection = myMessage.Parts
' Get the part named Body.
Dim myMessagePart As MessagePart = myMessage.Parts("Body")
If myMessagePartCollection.Contains(myMessagePart) Then
' Get the index of the part named Body.
Console.WriteLine("Index of Body in MessagePart collection = " & _
myMessagePartCollection.IndexOf(myMessagePart).ToString)
Console.WriteLine("Deleting Body from MessagePart Collection...")
myMessagePartCollection.Remove(myMessagePart)
If myMessagePartCollection.IndexOf(myMessagePart) = -1 Then
Console.WriteLine("MessagePart Body successfully deleted " & _
"from the message AddHttpPostOut.")
End If
End If
End If
Comentarios
Este método realiza una búsqueda lineal; por lo tanto, el tiempo medio de ejecución es proporcional a Count.
Los elementos que siguen al eliminado MessagePart se mueven hacia arriba para ocupar el lugar vacío.