ContactManager.DeleteContact Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee verwijdert u een PeerContact of PeerName van de ContactManager lokale peer.
Overloads
| Name | Description |
|---|---|
| DeleteContact(PeerContact) |
Hiermee verwijdert u de opgegeven PeerContact waarde uit de ContactManager lokale peer. |
| DeleteContact(PeerName) |
Hiermee verwijdert u de PeerContact gekoppelde aan de opgegeven PeerName van de ContactManager lokale peer. |
DeleteContact(PeerContact)
Hiermee verwijdert u de opgegeven PeerContact waarde uit de ContactManager lokale 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)
Parameters
- peerContact
- PeerContact
De PeerContact te verwijderen uit de ContactManager.
Uitzonderingen
peerContact is null.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u een PeerContact uit het lokale ContactManagerbestand verwijdert:
//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;
}
Opmerkingen
Voor het aanroepen van deze methode is een PermissionState van Unrestricted.
Zie ook
Van toepassing op
DeleteContact(PeerName)
Hiermee verwijdert u de PeerContact gekoppelde aan de opgegeven PeerName van de ContactManager lokale 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)
Parameters
- peerName
- PeerName
De PeerName gekoppelde aan de PeerContact te verwijderen uit de ContactManager.
- Kenmerken
Uitzonderingen
De PeerContact gekoppelde aan PeerName kan niet worden gevonden in de contactpersoonbeheerder.
peerName is null.
Dit object heeft het eerder aangeroepen Dispose() en kan niet worden gebruikt voor toekomstige bewerkingen.
Kan de bewerking niet voltooien DeleteContact .
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u een PeerContact uit het lokale ContactManagerbestand verwijdert:
//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;
}
Opmerkingen
Voor het aanroepen van deze methode is een PermissionState van Unrestricted.