MessageQueuePermissionEntryCollection.Insert 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将权限项插入此集合中指定的索引位置。
public:
void Insert(int index, System::Messaging::MessageQueuePermissionEntry ^ value);
public void Insert (int index, System.Messaging.MessageQueuePermissionEntry value);
member this.Insert : int * System.Messaging.MessageQueuePermissionEntry -> unit
Public Sub Insert (index As Integer, value As MessageQueuePermissionEntry)
参数
- index
- Int32
集合的从零开始的索引,将在此索引位置插入权限项。
将插入此集合中的权限项。
示例
以下代码示例演示了 Insert 的用法。
// 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);
// Create another new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry^ newEntry =
gcnew MessageQueuePermissionEntry(
MessageQueuePermissionAccess::Send,
queue->MachineName,
queue->Label,
queue->Category.ToString());
// Insert the new entry into the collection before the original entry.
collection->Insert(0, 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);
// Create another new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry newEntry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Send,
queue.MachineName,
queue.Label,
queue.Category.ToString());
// Insert the new entry into the collection before the original entry.
collection.Insert(0, newEntry);