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

Implemented Interfaces

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)
Adds a specified permission to the <see cref="T:System.Security.PermissionSet" /> .
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" /> .
perm The permission to add.
protected IPermission
AddPermissionImpl​(IPermission perm)
Adds a specified permission to the <see cref="T:System.Security.PermissionSet" /> .
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" /> .
perm The permission to add.
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​()
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" /> .
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" /> .
public static byte[]
ConvertPermissionSet​(string inFormat, byte[] inData, string outFormat)
Converts an encoded <see cref="T:System.Security.PermissionSet" /> from one XML encoding format to another XML encoding format.
Returns An encrypted permission set with the specified output format.
inFormat A string representing one of the following encoding formats: ASCII, Unicode, or Binary. Possible values are "XMLASCII" or "XML", "XMLUNICODE", and "BINARY".
inData An XML-encoded permission set.
outFormat A string representing one of the following encoding formats: ASCII, Unicode, or Binary. Possible values are "XMLASCII" or "XML", "XMLUNICODE", and "BINARY".
public PermissionSet
Copy​()
Creates a copy of the <see cref="T:System.Security.PermissionSet" /> .
Returns A copy of the <see cref="T:System.Security.PermissionSet" /> .
public void
CopyTo​(Array array, int index)
Copies the permission objects of the set to the indicated location in an <see cref="T:System.Array" /> .
array The target array to which to copy.
index The starting position in the array to begin copying (zero based).
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)
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" /> .
Returns <see langword="true" /> if the specified object is equal to the current <see cref="T:System.Security.PermissionSet" /> object; otherwise, <see langword="false" /> .
o The object to compare with the current <see cref="T:System.Security.PermissionSet" /> .
public void
FromXml​(SecurityElement et)
Reconstructs a security object with a specified state from an XML encoding.
et The XML encoding to use to reconstruct the security object.
GetEnumerator​()
Returns an enumerator for the permissions of the set.
Returns An enumerator object for the permissions of the set.
GetEnumeratorImpl​()
Returns an enumerator for the permissions of the set.
Returns An enumerator object for the permissions of the set.
public int
GetHashCode​()
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.
Returns A hash code for the current <see cref="T:System.Security.PermissionSet" /> object.
public IPermission
GetPermission​(Type permClass)
Gets a permission object of the specified type, if it exists in the set.
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.
permClass The type of the desired permission object.
protected IPermission
GetPermissionImpl​(Type permClass)
Gets a permission object of the specified type, if it exists in the set.
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.
permClass The type of the permission object.
public PermissionSet
Intersect​(PermissionSet other)
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" /> .
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.
other A permission set to intersect with the current <see cref="T:System.Security.PermissionSet" /> .
public bool
IsEmpty​()
Gets a value indicating whether the <see cref="T:System.Security.PermissionSet" /> is empty.
Returns <see langword="true" /> if the <see cref="T:System.Security.PermissionSet" /> is empty; otherwise, <see langword="false" /> .
public bool
IsSubsetOf​(PermissionSet target)
Determines whether the current <see cref="T:System.Security.PermissionSet" /> is a subset of the specified <see cref="T:System.Security.PermissionSet" /> .
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" /> .
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" /> .
public bool
IsUnrestricted​()
Determines whether the <see cref="T:System.Security.PermissionSet" /> is <see langword="Unrestricted" /> .
Returns <see langword="true" /> if the <see cref="T:System.Security.PermissionSet" /> is <see langword="Unrestricted" /> ; otherwise, <see langword="false" /> .
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)
Removes a permission of a certain type from the set.
Returns The permission removed from the set.
permClass The type of permission to delete.
protected IPermission
RemovePermissionImpl​(Type permClass)
Removes a permission of a certain type from the set.
Returns The permission removed from the set.
permClass The type of the permission to remove.
public static void
RevertAssert​()
Causes any previous <see cref="M:System.Security.CodeAccessPermission.Assert" /> for the current frame to be removed and no longer be in effect.
public IPermission
SetPermission​(IPermission perm)
Sets a permission to the <see cref="T:System.Security.PermissionSet" /> , replacing any existing permission of the same type.
Returns The set permission.
perm The permission to set.
protected IPermission
SetPermissionImpl​(IPermission perm)
Sets a permission to the <see cref="T:System.Security.PermissionSet" /> , replacing any existing permission of the same type.
Returns The set permission.
perm The permission to set.
public string
ToString​()
Returns a string representation of the <see cref="T:System.Security.PermissionSet" /> .
Returns A representation of the <see cref="T:System.Security.PermissionSet" /> .
ToXml​()
Creates an XML encoding of the security object and its current state.
Returns An XML encoding of the security object, including any state information.
public PermissionSet
Union​(PermissionSet other)
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" /> .
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" /> .
other The permission set to form the union with the current <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
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .