ResourcePermissionBase.AddPermissionAccess 方法

定义

将权限项添加到权限。

protected:
 void AddPermissionAccess(System::Security::Permissions::ResourcePermissionBaseEntry ^ entry);
protected void AddPermissionAccess (System.Security.Permissions.ResourcePermissionBaseEntry entry);
member this.AddPermissionAccess : System.Security.Permissions.ResourcePermissionBaseEntry -> unit
Protected Sub AddPermissionAccess (entry As ResourcePermissionBaseEntry)

参数

例外

PermissionAccessPath 属性中的元素数目不等于 TagNames 属性中的元素数目。

示例

以下示例演示了在类初始化期间使用 AddPermissionAccess 该方法添加权限访问条目。 此代码示例是为 ResourcePermissionBase 类提供的一个更大示例的一部分。

MailslotPermission( MailslotPermissionAccess permissionAccess, String^ name, String^ machineName )
{
   SetNames();
   this->AddPermissionAccess( gcnew MailslotPermissionEntry( permissionAccess,name,machineName ) );
}

MailslotPermission( array<MailslotPermissionEntry^>^permissionAccessEntries )
{
   SetNames();
   if ( permissionAccessEntries == nullptr )
         throw gcnew ArgumentNullException( "permissionAccessEntries" );

   for ( int index = 0; index < permissionAccessEntries->Length; ++index )
      this->AddPermissionAccess( permissionAccessEntries[ index ] );
}
public MailslotPermission(MailslotPermissionAccess permissionAccess, string name, string machineName)
{
    SetNames();
    this.AddPermissionAccess(new MailslotPermissionEntry(permissionAccess, name, machineName));
}

public MailslotPermission(MailslotPermissionEntry[] permissionAccessEntries)
{
    SetNames();
    if (permissionAccessEntries == null)
        throw new ArgumentNullException("permissionAccessEntries");

    for (int index = 0; index < permissionAccessEntries.Length; ++index)
        this.AddPermissionAccess(permissionAccessEntries[index]);
}
Public Sub New(ByVal permissionAccess As MailslotPermissionAccess, ByVal name As String, ByVal machineName1 As String)
    SetNames()
    Me.AddPermissionAccess(New MailslotPermissionEntry(permissionAccess, name, machineName1))
End Sub


Public Sub New(ByVal permissionAccessEntries() As MailslotPermissionEntry)
    SetNames()
    If permissionAccessEntries Is Nothing Then
        Throw New ArgumentNullException("permissionAccessEntries")
    End If
    Dim index As Integer

    While index < permissionAccessEntries.Length
        Me.AddPermissionAccess(permissionAccessEntries(index))
    End While
End Sub

适用于

另请参阅