ContactManager.DeleteContact Método

Definición

Quita PeerContact o PeerName del ContactManager del elemento local del mismo nivel.Removes a PeerContact or PeerName from the ContactManager of the local peer.

Sobrecargas

DeleteContact(PeerContact)

Quita el PeerContact especificado del ContactManager del mismo nivel local.Removes the specified PeerContact from the ContactManager of the local peer.

DeleteContact(PeerName)

Quita el PeerContact asociado al PeerName especificado del ContactManager del mismo nivel local.Removes the PeerContact associated with the specified PeerName from the ContactManager of the local peer.

DeleteContact(PeerContact)

Quita el PeerContact especificado del ContactManager del mismo nivel local.Removes the specified PeerContact from the ContactManager of the local peer.

public:
 void DeleteContact(System::Net::PeerToPeer::Collaboration::PeerContact ^ peerContact);
public void DeleteContact (System.Net.PeerToPeer.Collaboration.PeerContact peerContact);
member this.DeleteContact : System.Net.PeerToPeer.Collaboration.PeerContact -> unit
Public Sub DeleteContact (peerContact As PeerContact)

Parámetros

peerContact
PeerContact

PeerContact que se va a quitar de ContactManager.The PeerContact to remove from the ContactManager.

Excepciones

peerContact es null.peerContact is null.

Ejemplos

En el ejemplo de código siguiente se muestra cómo eliminar un PeerContact del local ContactManager :The following code example illustrates how to delete a PeerContact from the local ContactManager:

//Enumerating the contacts and letting the user choose which one to delete.
public static void DeleteContact()
{
    PeerContactCollection pcc = null;
    string contactToDelete = "";

    try
    {
        pcc = EnumContacts();
        if (pcc == null ||
            pcc.Count == 0)
        {
            Console.WriteLine("Contact list is empty -- no such contact exists.");
            return;
        }
        Console.Write("Please enter the nickname of the contact you wish to delete: ");
        contactToDelete = Console.ReadLine();

        foreach (PeerContact pc in pcc)
        {
            if (pc.Nickname.Equals(contactToDelete))
            {
                PeerCollaboration.ContactManager.DeleteContact(pc);
                Console.WriteLine("Contact {0} successfully deleted!", contactToDelete);
                return;
            }
        }
        Console.WriteLine("Contact {0} could not be found in the contact collection.", contactToDelete);
    }
    catch (ArgumentNullException argNullEx)
    {
        Console.WriteLine("The supplied contact is null: {0}", argNullEx.Message);
    }
    catch (ArgumentException argEx)
    {
        Console.WriteLine("The supplied contact \"{0}\" could not be found in the Contact Manager: {1}",
            contactToDelete, argEx.Message);
    }
    catch (PeerToPeerException p2pEx)
    {
        Console.WriteLine("The Peer Collaboration Infrastructure could not delete \"{0}\": {1}",
            contactToDelete, p2pEx.Message);
    }
    catch (Exception ex)
    {
        Console.WriteLine("Unexpected exception when trying to delete a contact : {0}", ex);
    }
    return;
}

Comentarios

La llamada a este método requiere un PermissionState de Unrestricted .Calling this method requires a PermissionState of Unrestricted.

Consulte también

Se aplica a

DeleteContact(PeerName)

Quita el PeerContact asociado al PeerName especificado del ContactManager del mismo nivel local.Removes the PeerContact associated with the specified PeerName from the ContactManager of the local peer.

public:
 void DeleteContact(System::Net::PeerToPeer::PeerName ^ peerName);
[System.Security.SecurityCritical]
public void DeleteContact (System.Net.PeerToPeer.PeerName peerName);
[<System.Security.SecurityCritical>]
member this.DeleteContact : System.Net.PeerToPeer.PeerName -> unit
Public Sub DeleteContact (peerName As PeerName)

Parámetros

peerName
PeerName

PeerName asociado a PeerContact para quitar de ContactManager.The PeerName associated with the PeerContact to remove from the ContactManager.

Atributos

Excepciones

El PeerContact asociado a PeerName no se encontró en el administrador de contactos.The PeerContact associated with PeerName could not be found in the contact manager.

peerName es null.peerName is null.

Se ha llamado previamente a Dispose() en este objeto y no se puede usar para operaciones futuras.This object has had Dispose() previously called on it and cannot be used for future operations.

No se puede completar la operación DeleteContact.Unable to complete DeleteContact operation.

Ejemplos

En el ejemplo de código siguiente se muestra cómo eliminar un PeerContact del local ContactManager :The following code example illustrates how to delete a PeerContact from the local ContactManager:

//Enumerating the contacts and letting the user choose which one to delete.
public static void DeleteContact()
{
    PeerContactCollection pcc = null;
    string contactToDelete = "";

    try
    {
        pcc = EnumContacts();
        if (pcc == null ||
            pcc.Count == 0)
        {
            Console.WriteLine("Contact list is empty -- no such contact exists.");
            return;
        }
        Console.Write("Please enter the nickname of the contact you wish to delete: ");
        contactToDelete = Console.ReadLine();

        foreach (PeerContact pc in pcc)
        {
            if (pc.Nickname.Equals(contactToDelete))
            {
                PeerCollaboration.ContactManager.DeleteContact(pc);
                Console.WriteLine("Contact {0} successfully deleted!", contactToDelete);
                return;
            }
        }
        Console.WriteLine("Contact {0} could not be found in the contact collection.", contactToDelete);
    }
    catch (ArgumentNullException argNullEx)
    {
        Console.WriteLine("The supplied contact is null: {0}", argNullEx.Message);
    }
    catch (ArgumentException argEx)
    {
        Console.WriteLine("The supplied contact \"{0}\" could not be found in the Contact Manager: {1}",
            contactToDelete, argEx.Message);
    }
    catch (PeerToPeerException p2pEx)
    {
        Console.WriteLine("The Peer Collaboration Infrastructure could not delete \"{0}\": {1}",
            contactToDelete, p2pEx.Message);
    }
    catch (Exception ex)
    {
        Console.WriteLine("Unexpected exception when trying to delete a contact : {0}", ex);
    }
    return;
}

Comentarios

La llamada a este método requiere un PermissionState de Unrestricted .Calling this method requires a PermissionState of Unrestricted.

Consulte también

Se aplica a