Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Security.​PermissionSet
Assembly: System.Runtime
Inheritance: object → PermissionSet
Represents a collection that can contain many different types of permissions.
Properties
public
int
Count
Gets the number of permission objects contained in the permission set.
public
bool
IsReadOnly
Gets a value indicating whether the collection is read-only.
public
bool
IsSynchronized
Gets a value indicating whether the collection is guaranteed to be thread safe.
public
object
SyncRoot
Gets the root object of the current collection.
Methods
public
IPermission
AddPermission​(IPermission perm)
perm
The permission to add.
Returns The union of the permission added and any permission of the same type that already exists in the <see cref="T:System.Security.PermissionSet" /> .
Adds a specified permission to the <see cref="T:System.Security.PermissionSet" /> .
protected
IPermission
AddPermissionImpl​(IPermission perm)
perm
The permission to add.
Returns The union of the permission added and any permission of the same type that already exists in the <see cref="T:System.Security.PermissionSet" /> , or <see langword="null" /> if <paramref name="perm" /> is <see langword="null" /> .
Adds a specified permission to the <see cref="T:System.Security.PermissionSet" /> .
public
void
Assert​()
Declares that the calling code can access the resource protected by a permission demand through the code that calls this method, even if callers higher in the stack have not been granted permission to access the resource. Using <see cref="M:System.Security.PermissionSet.Assert" /> can create security vulnerabilities.
public
bool
ContainsNonCodeAccessPermissions​() Returns <see langword="true" /> if the <see cref="T:System.Security.PermissionSet" /> contains permissions that are not derived from <see cref="T:System.Security.CodeAccessPermission" /> ; otherwise, <see langword="false" /> .
Gets a value indicating whether the <see cref="T:System.Security.PermissionSet" /> contains permissions that are not derived from <see cref="T:System.Security.CodeAccessPermission" /> .
public
PermissionSet
Copy​() Returns A copy of the <see cref="T:System.Security.PermissionSet" /> .
Creates a copy of the <see cref="T:System.Security.PermissionSet" /> .
public
void
CopyTo​(Array array,
int index)
array
The target array to which to copy.
index
The starting position in the array to begin copying (zero based).
Copies the permission objects of the set to the indicated location in an <see cref="T:System.Array" /> .
public
void
Demand​()
Forces a <see cref="T:System.Security.SecurityException" /> at run time if all callers higher in the call stack have not been granted the permissions specified by the current instance.
public
void
Deny​()
Causes any <see cref="M:System.Security.PermissionSet.Demand" /> that passes through the calling code for a permission that has an intersection with a permission of a type contained in the current <see cref="T:System.Security.PermissionSet" /> to fail.
public
bool
Equals​(object o)
o
The object to compare with the current <see cref="T:System.Security.PermissionSet" /> .
Returns <see langword="true" /> if the specified object is equal to the current <see cref="T:System.Security.PermissionSet" /> object; otherwise, <see langword="false" /> .
Determines whether the specified <see cref="T:System.Security.PermissionSet" /> or <see cref="T:System.Security.NamedPermissionSet" /> object is equal to the current <see cref="T:System.Security.PermissionSet" /> .
public
void
FromXml​(SecurityElement et)
et
The XML encoding to use to reconstruct the security object.
Reconstructs a security object with a specified state from an XML encoding.
GetEnumerator​()
Returns An enumerator object for the permissions of the set.
Returns an enumerator for the permissions of the set.
protected
Collections.​IEnumerator
GetEnumeratorImpl​() Returns An enumerator object for the permissions of the set.
Returns an enumerator for the permissions of the set.
public
int
GetHashCode​() Returns A hash code for the current <see cref="T:System.Security.PermissionSet" /> object.
Gets a hash code for the <see cref="T:System.Security.PermissionSet" /> object that is suitable for use in hashing algorithms and data structures such as a hash table.
public
IPermission
GetPermission​(Type permClass)
permClass
The type of the desired permission object.
Returns A copy of the permission object of the type specified by the <paramref name="permClass" /> parameter contained in the <see cref="T:System.Security.PermissionSet" /> , or <see langword="null" /> if none exists.
Gets a permission object of the specified type, if it exists in the set.
protected
IPermission
GetPermissionImpl​(Type permClass)
permClass
The type of the permission object.
Returns A copy of the permission object, of the type specified by the <paramref name="permClass" /> parameter, contained in the <see cref="T:System.Security.PermissionSet" /> , or <see langword="null" /> if none exists.
Gets a permission object of the specified type, if it exists in the set.
public
PermissionSet
Intersect​(PermissionSet other)
other
A permission set to intersect with the current <see cref="T:System.Security.PermissionSet" /> .
Returns A new permission set that represents the intersection of the current <see cref="T:System.Security.PermissionSet" /> and the specified target. This object is <see langword="null" /> if the intersection is empty.
Creates and returns a permission set that is the intersection of the current <see cref="T:System.Security.PermissionSet" /> and the specified <see cref="T:System.Security.PermissionSet" /> .
public
bool
IsEmpty​() Returns <see langword="true" /> if the <see cref="T:System.Security.PermissionSet" /> is empty; otherwise, <see langword="false" /> .
Gets a value indicating whether the <see cref="T:System.Security.PermissionSet" /> is empty.
public
bool
IsSubsetOf​(PermissionSet target)
target
The permission set to test for the subset relationship. This must be either a <see cref="T:System.Security.PermissionSet" /> or a <see cref="T:System.Security.NamedPermissionSet" /> .
Returns <see langword="true" /> if the current <see cref="T:System.Security.PermissionSet" /> is a subset of the <paramref name="target" /> parameter; otherwise, <see langword="false" /> .
Determines whether the current <see cref="T:System.Security.PermissionSet" /> is a subset of the specified <see cref="T:System.Security.PermissionSet" /> .
public
bool
IsUnrestricted​() Returns <see langword="true" /> if the <see cref="T:System.Security.PermissionSet" /> is <see langword="Unrestricted" /> ; otherwise, <see langword="false" /> .
Determines whether the <see cref="T:System.Security.PermissionSet" /> is <see langword="Unrestricted" /> .
public
void
PermitOnly​()
Causes any <see cref="M:System.Security.PermissionSet.Demand" /> that passes through the calling code for any <see cref="T:System.Security.PermissionSet" /> that is not a subset of the current <see cref="T:System.Security.PermissionSet" /> to fail.
public
IPermission
RemovePermission​(Type permClass)
permClass
The type of permission to delete.
Returns The permission removed from the set.
Removes a permission of a certain type from the set.
protected
IPermission
RemovePermissionImpl​(Type permClass)
permClass
The type of the permission to remove.
Returns The permission removed from the set.
Removes a permission of a certain type from the set.
public
IPermission
SetPermission​(IPermission perm)
perm
The permission to set.
Returns The set permission.
Sets a permission to the <see cref="T:System.Security.PermissionSet" /> , replacing any existing permission of the same type.
protected
IPermission
SetPermissionImpl​(IPermission perm)
perm
The permission to set.
Returns The set permission.
Sets a permission to the <see cref="T:System.Security.PermissionSet" /> , replacing any existing permission of the same type.
public
string
ToString​() Returns A representation of the <see cref="T:System.Security.PermissionSet" /> .
Returns a string representation of the <see cref="T:System.Security.PermissionSet" /> .
public
SecurityElement
ToXml​() Returns An XML encoding of the security object, including any state information.
Creates an XML encoding of the security object and its current state.
public
PermissionSet
Union​(PermissionSet other)
other
The permission set to form the union with the current <see cref="T:System.Security.PermissionSet" /> .
Returns A new permission set that represents the union of the current <see cref="T:System.Security.PermissionSet" /> and the specified <see cref="T:System.Security.PermissionSet" /> .
Creates a <see cref="T:System.Security.PermissionSet" /> that is the union of the current <see cref="T:System.Security.PermissionSet" /> and the specified <see cref="T:System.Security.PermissionSet" /> .
protected
void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public
Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected
object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .