다음을 통해 공유


MessageQueuePermissionEntry 클래스

정의

메시징에 대해 설정된 코드 액세스 보안 권한의 최소 단위를 정의합니다.

public ref class MessageQueuePermissionEntry
[System.Serializable]
public class MessageQueuePermissionEntry
[<System.Serializable>]
type MessageQueuePermissionEntry = class
Public Class MessageQueuePermissionEntry
상속
MessageQueuePermissionEntry
특성

예제

다음 코드 예제에서는 MessageQueuePermissionEntry의 사용법을 보여줍니다.


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

using namespace System;
using namespace System::Messaging;

public ref class MessageQueuePermissionEntryExample
{
    // Creates a new queue.
public:
    static 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 following MessageQueuePermission constructor:
    // public #ctor (MessageQueuePermissionAccess permissionAccess,
    //  String path)
public:
    void CreateEntryShortCtor()
    {
        // Connect to a queue on the local computer.
        MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

        // Create a new instance of MessageQueuePermissionEntry.
        MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry(
            MessageQueuePermissionAccess::Receive,
            queue->Path);

        queue->Close(); 
    }

    // Demonstrates the following MessageQueuePermission constructor:
    // public #ctor (MessageQueuePermissionAccess permissionAccess,
    //  String machineName, String label, String category)
public:
    void CreateEntryLongCtor()
    {
        // Connect to a queue on the local computer.
        MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

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

        queue->Close();
    }

public:
    void CategoryExample()
    {
        // Connect to a queue on the local computer.
        MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

        // Create a new instance of MessageQueuePermissionEntry.
        MessageQueuePermissionEntry^ entry = gcnew 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());

        queue->Close();
    }

public:
    void LabelExample()
    {
        // Connect to a queue on the local computer.
        MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

        // Create a new instance of MessageQueuePermissionEntry.
        MessageQueuePermissionEntry^ entry = gcnew 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);

        queue->Close();
    }

public:
    void MachineNameExample()
    {
        // Connect to a queue on the local computer.
        MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

        // Create a new instance of MessageQueuePermissionEntry.
        MessageQueuePermissionEntry^ entry = gcnew 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);

        queue->Close();
    }

public:
    void PathExample()
    {
        // Connect to a queue on the local computer.
        MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

        // Create a new instance of MessageQueuePermissionEntry.
        MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry(
            MessageQueuePermissionAccess::Receive,
            queue->Path);

        // Display the value of the entry's Path property.
        Console::WriteLine("Path: {0}", entry->Path);

        queue->Close();
    }

public:
    void PermissionAccessExample()
    {
        // Connect to a queue on the local computer.
        MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

        // Create a new instance of MessageQueuePermissionEntry.
        MessageQueuePermissionEntry^ entry = gcnew 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);
 
        queue->Close(); 
    }
};

int main()
{
    // Create a new instance of the class.
    MessageQueuePermissionEntryExample^ example =
        gcnew MessageQueuePermissionEntryExample();

    try
    {
        // Create a non-transactional queue on the local computer.
        // Note that the queue might not be immediately accessible, and
        // therefore this example might throw an exception of type
        // System.Messaging.MessageQueueException when trying to send a
        // message to the newly created queue.
        example->CreateQueue(".\\exampleQueue", false);

        // Demonstrate MessageQueuePermissionEntry's constructors.
        example->CreateEntryShortCtor();
        example->CreateEntryLongCtor();

        // Demonstrate MessageQueuePermissionEntry's properties.
        example->CategoryExample();
        example->LabelExample();
        example->MachineNameExample();
        example->PathExample();
        example->PermissionAccessExample();
    }

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

    catch (MessageQueueException^ ex)
    {
        // Write the exception information to the console.
        Console::WriteLine(ex->Message);
    }
}
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);
    }
}

설명

자세한 내용은 코드 액세스 보안합니다.

생성자

MessageQueuePermissionEntry(MessageQueuePermissionAccess, String)

지정된 권한 액세스 수준과 큐 경로를 사용하여 MessageQueuePermissionEntry 클래스의 새 인스턴스를 초기화합니다.

MessageQueuePermissionEntry(MessageQueuePermissionAccess, String, String, String)

지정된 권한 액세스 수준, 큐가 있는 컴퓨터 이름, 큐 설명 및 큐 범주를 사용하여 MessageQueuePermissionEntry 클래스의 새 인스턴스를 초기화합니다.

속성

Category

큐 범주를 가져옵니다.

Label

큐 설명을 가져옵니다.

MachineName

메시지 큐가 있는 컴퓨터의 이름을 가져옵니다.

Path

큐 경로를 가져옵니다.

PermissionAccess

권한 요청에 사용할 권한 액세스 수준을 가져옵니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보