ResourcePermissionBase.AddPermissionAccess 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将权限项添加到权限。
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)
参数
例外
指定的 ResourcePermissionBaseEntry 为 null
。
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