共用方式為


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 屬性中的項目數目。

-或- ResourcePermissionBaseEntry 已包含於使用權限。

範例

下列範例示範 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

適用於

另請參閱