PermissionSet 构造函数

定义

初始化 PermissionSet 类的新实例。

重载

PermissionSet(PermissionState)

使用指定的 PermissionSet 初始化 PermissionState 类的新实例。

PermissionSet(PermissionSet)

使用从 permSet 参数获取的初始值初始化 PermissionSet 类的新实例。

PermissionSet(PermissionState)

Source:
PermissionSet.cs
Source:
PermissionSet.cs
Source:
PermissionSet.cs

使用指定的 PermissionSet 初始化 PermissionState 类的新实例。

public:
 PermissionSet(System::Security::Permissions::PermissionState state);
public PermissionSet (System.Security.Permissions.PermissionState state);
new System.Security.PermissionSet : System.Security.Permissions.PermissionState -> System.Security.PermissionSet
Public Sub New (state As PermissionState)

参数

state
PermissionState

指定资源访问权限集的其中一个枚举值。

例外

state 参数不是有效的 PermissionState

示例

下面的代码示例演示如何使用 PermissionSet 构造函数创建权限状态为 的权限 None集。 此代码示例是为 PermissionSet 类提供的一个更大示例的一部分。

// Open a new PermissionSet.
PermissionSet^ ps1 = gcnew PermissionSet( PermissionState::None );

Console::WriteLine( "Adding permission to open a file from a file dialog box." );

// Add a permission to the permission set.
ps1->AddPermission( gcnew FileDialogPermission( FileDialogPermissionAccess::Open ) );

Console::WriteLine( "Demanding permission to open a file." );
ps1->Demand();
Console::WriteLine( "Demand succeeded." );
// Open a new PermissionSet.
PermissionSet ps1 = new PermissionSet(PermissionState.None);
Console.WriteLine("Adding permission to open a file from a file dialog box.");
// Add a permission to the permission set.
ps1.AddPermission(
    new FileDialogPermission(FileDialogPermissionAccess.Open));
Console.WriteLine("Demanding permission to open a file.");
ps1.Demand();
Console.WriteLine("Demand succeeded.");
' Open a new PermissionSet.
Dim ps1 As New PermissionSet(PermissionState.None)
Console.WriteLine("Adding permission to open a file from a file dialog box.")
' Add a permission to the permission set.
ps1.AddPermission(New FileDialogPermission(FileDialogPermissionAccess.Open))
Console.WriteLine("Demanding permission to open a file.")
ps1.Demand()
Console.WriteLine("Demand succeeded.")

注解

状态 Unrestricted 允许实现 IUnrestrictedPermission 接口的所有权限,而 None 不允许任何权限。

AddPermissionPermissionSet 使用 更详细地定义集。

适用于

PermissionSet(PermissionSet)

Source:
PermissionSet.cs
Source:
PermissionSet.cs
Source:
PermissionSet.cs

使用从 permSet 参数获取的初始值初始化 PermissionSet 类的新实例。

public:
 PermissionSet(System::Security::PermissionSet ^ permSet);
public PermissionSet (System.Security.PermissionSet? permSet);
public PermissionSet (System.Security.PermissionSet permSet);
new System.Security.PermissionSet : System.Security.PermissionSet -> System.Security.PermissionSet
Public Sub New (permSet As PermissionSet)

参数

permSet
PermissionSet

若为权限集,则从中获取新 PermissionSet 的值;若为 null,则创建空的 PermissionSet

注解

新的 PermissionSet 包含指定 PermissionSet中包含的权限的副本。

注意

当 参数不是 null时,permSet这等效于 Copy

适用于