// Demonstrates: // public Int32 Add (MessageQueuePermissionEntry value) public void AddExample() { // <snippet1> // 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); // </snippet1> }
// Demonstrates: // public Void Insert (Int32 index, MessageQueuePermissionEntry value) public void InsertExample() { // <snippet7> // 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); // </snippet7> }
// Demonstrates: // public Int32 IndexOf (MessageQueuePermissionEntry value) public void IndexOfExample() { // <snippet6> // 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); // Display the index of the entry in the collection. Console.WriteLine("Collection contains entry at index: {0}", collection.IndexOf(entry)); // </snippet6> }
// Demonstrates: // public MessageQueuePermissionEntry Item [Int32 index] { get; set; } public void ItemExample() { // 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); // Display the entry's properties, using the collection's Item // accessor. Console.WriteLine("collection[0].PermissionAccess: {0}", collection[0].PermissionAccess); Console.WriteLine("collection[0].MachineName: {0}", collection[0].MachineName); Console.WriteLine("collection[0].Label: {0}", collection[0].Label); Console.WriteLine("collection[0].Category: {0}", collection[0].Category.ToString()); }
// Demonstrates: // public Void CopyTo (MessageQueuePermissionEntry[] array, Int32 index) public void CopyToExample() { // <snippet5> // 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 an array of type MessageQueuePermissionEntry. MessageQueuePermissionEntry[] entries = new MessageQueuePermissionEntry[1]; // Copy the collection to index 0 of the array. collection.CopyTo(entries, 0); // Show that the array now contains the entry. Console.WriteLine("entries[0].PermissionAccess: {0}", entries[0].PermissionAccess); Console.WriteLine("entries[0].MachineName: {0}", entries[0].MachineName); Console.WriteLine("entries[0].Label: {0}", entries[0].Label); Console.WriteLine("entries[0].Category: {0}", entries[0].Category.ToString()); // </snippet5> }
// Demonstrates: // public Boolean Contains (MessageQueuePermissionEntry value) public void ContainsExample() { // <snippet4> // 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)); // </snippet4> }