Bagikan melalui


MessageQueuePermissionAccess Enum

Definisi

Menentukan tingkat akses yang digunakan oleh System.Messaging kelas izin.

Enumerasi ini mendukung kombinasi bitwise dari nilai yang termasuk di dalamnya.

public enum class MessageQueuePermissionAccess
[System.Flags]
public enum MessageQueuePermissionAccess
[System.Flags]
[System.Serializable]
public enum MessageQueuePermissionAccess
[<System.Flags>]
type MessageQueuePermissionAccess = 
[<System.Flags>]
[<System.Serializable>]
type MessageQueuePermissionAccess = 
Public Enum MessageQueuePermissionAccess
Warisan
MessageQueuePermissionAccess
Atribut

Bidang

Administer 62

MessageQueue dapat melihat antrean yang tersedia, membaca pesan dalam antrean, dan mengirim dan menerima pesan.

Browse 2

MessageQueue dapat melihat antrean yang tersedia.

None 0

tidak MessageQueue memiliki izin.

Peek 10

MessageQueue dapat melihat antrean yang tersedia dan membaca pesan dalam antrean.

Receive 26

MessageQueue dapat melihat antrean yang tersedia, membaca pesan dalam antrean, dan menerima pesan.

Send 6

MessageQueue dapat melihat antrean yang tersedia dan mengirim pesan.

Contoh

Contoh kode berikut menggunakan dalam membuat instans MessageQueuePermissionAccess baru .MessageQueuePermission


#using <System.dll>
#using <System.Messaging.dll>

using namespace System;
using namespace System::Messaging;

// Creates a new queue.
void CreateQueue(String^ queuePath, bool transactional)
{
    if (!MessageQueue::Exists(queuePath))
    {
        MessageQueue^ queue = MessageQueue::Create(queuePath, transactional);
        queue->Close();       
    }
    else
    {
        Console::WriteLine("{0} already exists.",queuePath);
    }
}

// Demonstrates the use of MessageQueuePermissionAccess
void CreatePermission()
{
    // Connect to a queue on the local computer.
    MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

    // Create a new instance of MessageQueuePermission.
    MessageQueuePermission^ permission = gcnew MessageQueuePermission(
        MessageQueuePermissionAccess::Receive, queue->MachineName,
        queue->Label, queue->Category.ToString());

    queue->Close();
}

int main()
{
    try
    {

        // Create a non-transactional queue on the local computer.
        CreateQueue(".\\exampleQueue", false);

        // Demonstrate use of MessageQueuePermissionAccess.
        CreatePermission();
    }

    catch (InvalidOperationException^)
    {
        Console::WriteLine("Please install Message Queuing.");
    }

    catch (MessageQueueException^ ex)
    {
        Console::WriteLine(ex->Message);
    }
}
using System;
using System.Messaging;

public class MessageQueuePermissionAccessExample
{
    public static void Main()
    {
        // Create a new instance of the class.
        MessageQueuePermissionAccessExample example =
            new MessageQueuePermissionAccessExample();

        // Create a non-transactional queue on the local computer.
        CreateQueue(".\\exampleQueue", false);

        // Demonstrate use of MessageQueuePermissionAccess.
        example.CreatePermission();
    }

    // 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 use of MessageQueuePermissionAccess
    public void CreatePermission()
    {
        // Connect to a queue on the local computer.
        MessageQueue queue = new MessageQueue(".\\exampleQueue");
    string machineName = queue.MachineName;
    string label = queue.Label;
        string category = queue.Category.ToString();
        // Create a new instance of MessageQueuePermission.
        MessageQueuePermission permission = new MessageQueuePermission(
            MessageQueuePermissionAccess.Receive,
            machineName,
            label,
            category);
    }
}

Berlaku untuk

Lihat juga