MessageQueuePermissionEntryCollection.Contains Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Определяет, содержит ли данная коллекция указанный объект MessageQueuePermissionEntry.
public:
bool Contains(System::Messaging::MessageQueuePermissionEntry ^ value);
public bool Contains (System.Messaging.MessageQueuePermissionEntry value);
member this.Contains : System.Messaging.MessageQueuePermissionEntry -> bool
Public Function Contains (value As MessageQueuePermissionEntry) As Boolean
Параметры
Искомый объект MessageQueuePermissionEntry.
Возвращаемое значение
Значение true
, если указанный объект MessageQueuePermissionEntry принадлежит данной коллекции; в противном случае — значение false
.
Примеры
В следующем коде показано использование функции Contains.
// Connect to a queue on the local computer.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermission.
MessageQueuePermission^ permission = gcnew MessageQueuePermission();
// Get an instance of MessageQueuePermissionEntryCollection from the
// permission's PermissionEntries property.
MessageQueuePermissionEntryCollection^ collection =
permission->PermissionEntries;
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry(
MessageQueuePermissionAccess::Receive,
queue->MachineName,
queue->Label,
queue->Category.ToString());
// Add the entry to the collection.
collection->Add(entry);
// Show that the collection contains the entry.
Console::WriteLine("Collection contains first entry (true/false): {0}",
collection->Contains(entry));
// Create another new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry^ newEntry =
gcnew MessageQueuePermissionEntry(
MessageQueuePermissionAccess::Send,
queue->MachineName,
queue->Label,
queue->Category.ToString());
// Show that the collection does not contain the new entry.
Console::WriteLine(
"Collection contains second entry (true/false): {0}",
collection->Contains(newEntry));
queue->Close();
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermission.
MessageQueuePermission permission = new MessageQueuePermission();
// Get an instance of MessageQueuePermissionEntryCollection from the
// permission's PermissionEntries property.
MessageQueuePermissionEntryCollection collection =
permission.PermissionEntries;
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.MachineName,
queue.Label,
queue.Category.ToString());
// Add the entry to the collection.
collection.Add(entry);
// Show that the collection contains the entry.
Console.WriteLine("Collection contains first entry (true/false): {0}",
collection.Contains(entry));
// Create another new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry newEntry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Send,
queue.MachineName,
queue.Label,
queue.Category.ToString());
// Show that the collection does not contain the new entry.
Console.WriteLine("Collection contains second entry (true/false): {0}",
collection.Contains(newEntry));