次の方法で共有


MessageQueuePermissionEntryCollection.Insert メソッド

定義

コレクションの指定したインデックス位置にアクセス許可エントリを挿入します。

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

アクセス許可エントリを挿入するコレクション内の 0 から始まるインデックス番号。

value
MessageQueuePermissionEntry

コレクションに挿入するアクセス許可エントリ。

次のコード例は、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);

適用対象