PermissionSet PermissionSet PermissionSet Constructors

Definition

Overloads

PermissionSet(PermissionState) PermissionSet(PermissionState) PermissionSet(PermissionState)

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

PermissionSet(PermissionSet) PermissionSet(PermissionSet) PermissionSet(PermissionSet)

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

PermissionSet(PermissionState) PermissionSet(PermissionState) PermissionSet(PermissionState)

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);
Public Sub New (state As PermissionState)
Parameters
state
PermissionState PermissionState PermissionState

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

Exceptions

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.

PermissionSet(PermissionSet) PermissionSet(PermissionSet) PermissionSet(PermissionSet)

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 Sub New (permSet As PermissionSet)
Parameters
permSet
PermissionSet PermissionSet 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