Επεξεργασία

Κοινή χρήση μέσω


PermissionSet Constructors

Definition

Initializes a new instance of the PermissionSet class.

Overloads

PermissionSet(PermissionState)

Initializes a new instance of the PermissionSet class with the specified PermissionState.

PermissionSet(PermissionSet)

Initializes a new instance of the PermissionSet class with initial values taken from the permSet parameter.

PermissionSet(PermissionState)

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

Initializes a new instance of the PermissionSet class with the specified 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)

Parameters

state
PermissionState

One of the enumeration values that specifies the permission set's access to resources.

Exceptions

The state parameter is not a valid PermissionState.

Examples

The following code example shows the use of the PermissionSet constructor to create a permission set with a permission state of None. This code example is part of a larger example provided for the PermissionSet class.

// 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.")

Remarks

The Unrestricted state allows all permissions that implement the IUnrestrictedPermission interface, while None allows no permissions.

Use AddPermission on an empty PermissionSet to define the set in greater detail.

Applies to

PermissionSet(PermissionSet)

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

Initializes a new instance of the PermissionSet class with initial values taken from the permSet parameter.

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)

Parameters

permSet
PermissionSet

The set from which to take the value of the new PermissionSet, or null to create an empty PermissionSet.

Remarks

The new PermissionSet contains copies of the permissions contained in the specified PermissionSet.

Note

This is equivalent to Copy when the permSet parameter is not null.

Applies to