本文整理汇总了C#中System.Messaging.MessageQueuePermissionEntry类的典型用法代码示例。如果您正苦于以下问题:C# MessageQueuePermissionEntry类的具体用法?C# MessageQueuePermissionEntry怎么用?C# MessageQueuePermissionEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageQueuePermissionEntry类属于System.Messaging命名空间,在下文中一共展示了MessageQueuePermissionEntry类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Messaging;
public class MessageQueuePermissionEntryExample
{
public static void Main()
{
// Create a new instance of the class.
MessageQueuePermissionEntryExample example =
new MessageQueuePermissionEntryExample();
// Create a non-transactional queue on the local computer.
CreateQueue(".\\exampleQueue", false);
// Demonstrate MessageQueuePermissionEntry's constructors.
example.CreateEntry1();
example.CreateEntry2();
// Demonstrate MessageQueuePermissionEntry's properties.
example.CategoryExample();
example.LabelExample();
example.MachineNameExample();
example.PathExample();
example.PermissionAccessExample();
}
// Creates a new queue.
public static void CreateQueue(string queuePath, bool transactional)
{
if(!MessageQueue.Exists(queuePath))
{
MessageQueue.Create(queuePath, transactional);
}
else
{
Console.WriteLine(queuePath + " already exists.");
}
}
// Demonstrates the following MessageQueuePermission constructor:
// public #ctor (MessageQueuePermissionAccess permissionAccess,
// String path)
public void CreateEntry1()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.Path);
}
// Demonstrates the following MessageQueuePermission constructor:
// public #ctor (MessageQueuePermissionAccess permissionAccess,
// String machineName, String label, String category)
public void CreateEntry2()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.MachineName,
queue.Label,
queue.Category.ToString());
}
public void CategoryExample()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.MachineName,
queue.Label,
queue.Category.ToString());
// Display the value of the entry's Category property.
Console.WriteLine("Category: {0}", entry.Category.ToString());
}
public void LabelExample()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.MachineName,
queue.Label,
queue.Category.ToString());
// Display the value of the entry's Label property.
Console.WriteLine("Label: {0}", entry.Label);
}
public void MachineNameExample()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.MachineName,
queue.Label,
queue.Category.ToString());
// Display the value of the entry's MachineName property.
Console.WriteLine("MachineName: {0}", entry.MachineName);
}
public void PathExample()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.Path);
// Display the value of the entry's Path property.
Console.WriteLine("Path: {0}", entry.Path);
}
public void PermissionAccessExample()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.MachineName,
queue.Label,
queue.Category.ToString());
// Display the value of the entry's PermissionAccess property.
Console.WriteLine("PermissionAccess: {0}", entry.PermissionAccess);
}
}