共用方式為


PermissionSet 建構函式

定義

初始化 PermissionSet 類別的新執行個體。

多載

PermissionSet(PermissionState)

使用指定的 PermissionSet 初始化 PermissionState 類別的新執行個體。

PermissionSet(PermissionSet)

以取自 permSet 參數的初始值,初始化 PermissionSet 類別的新執行個體。

PermissionSet(PermissionState)

來源:
PermissionSet.cs
來源:
PermissionSet.cs
來源:
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 不允許任何許可權。

AddPermission 空白 PermissionSet 上使用 ,以更詳細地定義集合。

適用於

PermissionSet(PermissionSet)

來源:
PermissionSet.cs
來源:
PermissionSet.cs
來源:
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 值的集合,或要建立空 PermissionSetnull

備註

新的 PermissionSet 包含指定 PermissionSet中所含許可權的複本。

注意

當 參數不是 null時,permSet這相當於 Copy

適用於