ContactManager.DeleteContact Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Удаляет PeerContact или PeerName удаляется из ContactManager локального однорангового узла.
Перегрузки
| Имя | Описание |
|---|---|
| DeleteContact(PeerContact) |
Удаляет указанный PeerContact из ContactManager локального однорангового узла. |
| DeleteContact(PeerName) |
Удаляет PeerContact связанный с указанным PeerNameContactManager одноранговым элементом локальный узел. |
DeleteContact(PeerContact)
Удаляет указанный PeerContact из ContactManager локального однорангового узла.
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)
Параметры
- peerContact
- PeerContact
Удаление PeerContact из .ContactManager
Исключения
peerContact равно null.
Примеры
В следующем примере кода показано удаление PeerContact из локального 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;
}
Комментарии
Для вызова этого метода требуется PermissionStateUnrestrictedзначение .
См. также раздел
Применяется к
DeleteContact(PeerName)
Удаляет PeerContact связанный с указанным PeerNameContactManager одноранговым элементом локальный узел.
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)
Параметры
- peerName
- PeerName
Связанный PeerName с удалением PeerContact из него ContactManager.
- Атрибуты
Исключения
Связанный PeerContact с PeerName ним не удалось найти в диспетчере контактов.
peerName равно null.
Этот объект Dispose() ранее вызвал его и не может использоваться для будущих операций.
Не удалось завершить DeleteContact операцию.
Примеры
В следующем примере кода показано удаление PeerContact из локального 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;
}
Комментарии
Для вызова этого метода требуется PermissionStateUnrestrictedзначение .