MessageQueuePermissionAttribute.CreatePermission 方法

定义

基于请求的访问级别、类别、标签、计算机名称和路径(它们是通过有关该特性上的 PermissionAccessCategoryLabelMachineNamePath 属性分别设置的)创建权限。

public:
 override System::Security::IPermission ^ CreatePermission();
public override System.Security.IPermission CreatePermission ();
override this.CreatePermission : unit -> System.Security.IPermission
Public Overrides Function CreatePermission () As IPermission

返回

一个 IPermission,它表示创建的权限。

示例

下面的代码示例调用 CreatePermission


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

// Create a new instance of MessageQueuePermissionAttribute.
MessageQueuePermissionAttribute^ attribute =
    gcnew MessageQueuePermissionAttribute(
    System::Security::Permissions::SecurityAction::Assert);

// Set the attribute's Path property value, based on the queue's Path
// property value.
attribute->Path = queue->Path;

// Get an IPermission interface by calling the attribute's
// CreatePermission() method.
System::Security::IPermission^ permission = attribute->CreatePermission();

queue->Close();

// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");

// Create a new instance of MessageQueuePermissionAttribute.
MessageQueuePermissionAttribute attribute =
    new MessageQueuePermissionAttribute(
    System.Security.Permissions.SecurityAction.Assert);

// Set the attribute's Path property value, based on the queue's Path
// property value.
attribute.Path = queue.Path;

// Get an IPermission interface by calling the attribute's
// CreatePermission() method.
System.Security.IPermission permission = attribute.CreatePermission();

适用于