mscorlib(4.0.0.0) API with additions
System.Security.PermissionSet Class Reference

Represents a collection that can contain many different types of permissions. More...

Inheritance diagram for System.Security.PermissionSet:
[legend]
Collaboration diagram for System.Security.PermissionSet:
[legend]

Public Member Functions

 PermissionSet (PermissionState state)
 Initializes a new instance of the T:System.Security.PermissionSet class with the specified T:System.Security.Permissions.PermissionState. More...
 
 PermissionSet (PermissionSet permSet)
 Initializes a new instance of the T:System.Security.PermissionSet class with initial values taken from the permSet parameter. More...
 
virtual void CopyTo (Array array, int index)
 Copies the permission objects of the set to the indicated location in an T:System.Array. More...
 
bool IsEmpty ()
 Gets a value indicating whether the T:System.Security.PermissionSet is empty. More...
 
IPermission GetPermission (Type permClass)
 Gets a permission object of the specified type, if it exists in the set. More...
 
IPermission SetPermission (IPermission perm)
 Sets a permission to the T:System.Security.PermissionSet, replacing any existing permission of the same type. More...
 
IPermission AddPermission (IPermission perm)
 Adds a specified permission to the T:System.Security.PermissionSet. More...
 
IPermission RemovePermission (Type permClass)
 Removes a permission of a certain type from the set. More...
 
bool IsUnrestricted ()
 Determines whether the T:System.Security.PermissionSet is Unrestricted. More...
 
bool IsSubsetOf (PermissionSet target)
 Determines whether the current T:System.Security.PermissionSet is a subset of the specified T:System.Security.PermissionSet. More...
 
PermissionSet Intersect (PermissionSet other)
 Creates and returns a permission set that is the intersection of the current T:System.Security.PermissionSet and the specified T:System.Security.PermissionSet. More...
 
PermissionSet Union (PermissionSet other)
 Creates a T:System.Security.PermissionSet that is the union of the current T:System.Security.PermissionSet and the specified T:System.Security.PermissionSet. More...
 
override bool Equals (object obj)
 Determines whether the specified T:System.Security.PermissionSet or T:System.Security.NamedPermissionSet object is equal to the current T:System.Security.PermissionSet. More...
 
override int GetHashCode ()
 Gets a hash code for the T:System.Security.PermissionSet object that is suitable for use in hashing algorithms and data structures such as a hash table. More...
 
void Demand ()
 Forces a 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. More...
 
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 M:System.Security.PermissionSet.Assert can create security vulnerabilities. More...
 
void Deny ()
 Causes any 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 T:System.Security.PermissionSet to fail. More...
 
void PermitOnly ()
 Causes any M:System.Security.PermissionSet.Demand that passes through the calling code for any T:System.Security.PermissionSet that is not a subset of the current T:System.Security.PermissionSet to fail. More...
 
virtual PermissionSet Copy ()
 Creates a copy of the T:System.Security.PermissionSet. More...
 
IEnumerator GetEnumerator ()
 Returns an enumerator for the permissions of the set. More...
 
override string ToString ()
 Returns a string representation of the T:System.Security.PermissionSet. More...
 
virtual void FromXml (SecurityElement et)
 Reconstructs a security object with a specified state from an XML encoding. More...
 
virtual SecurityElement ToXml ()
 Creates an XML encoding of the security object and its current state. More...
 
bool ContainsNonCodeAccessPermissions ()
 Gets a value indicating whether the T:System.Security.PermissionSet contains permissions that are not derived from T:System.Security.CodeAccessPermission. More...
 

Static Public Member Functions

static byte [] ConvertPermissionSet (string inFormat, byte[] inData, string outFormat)
 Converts an encoded T:System.Security.PermissionSet from one XML encoding format to another XML encoding format. More...
 
static void RevertAssert ()
 Causes any previous M:System.Security.CodeAccessPermission.Assert for the current frame to be removed and no longer be in effect. More...
 

Public Attributes

virtual object SyncRoot => this
 Gets the root object of the current collection. More...
 
virtual bool IsSynchronized => false
 Gets a value indicating whether the collection is guaranteed to be thread safe. More...
 
virtual bool IsReadOnly => false
 Gets a value indicating whether the collection is read-only. More...
 

Protected Member Functions

virtual IPermission GetPermissionImpl (Type permClass)
 Gets a permission object of the specified type, if it exists in the set. More...
 
virtual IPermission SetPermissionImpl (IPermission perm)
 Sets a permission to the T:System.Security.PermissionSet, replacing any existing permission of the same type. More...
 
virtual IPermission AddPermissionImpl (IPermission perm)
 Adds a specified permission to the T:System.Security.PermissionSet. More...
 
virtual IPermission RemovePermissionImpl (Type permClass)
 Removes a permission of a certain type from the set. More...
 
virtual IEnumerator GetEnumeratorImpl ()
 Returns an enumerator for the permissions of the set. More...
 

Properties

virtual int Count [get]
 Gets the number of permission objects contained in the permission set. More...
 
- Properties inherited from System.Collections.ICollection
int Count [get]
 Gets the number of elements contained in the T:System.Collections.ICollection. More...
 
object SyncRoot [get]
 Gets an object that can be used to synchronize access to the T:System.Collections.ICollection. More...
 
bool IsSynchronized [get]
 Gets a value indicating whether access to the T:System.Collections.ICollection is synchronized (thread safe). More...
 

Detailed Description

Represents a collection that can contain many different types of permissions.

Definition at line 20 of file PermissionSet.cs.

Constructor & Destructor Documentation

◆ PermissionSet() [1/2]

System.Security.PermissionSet.PermissionSet ( PermissionState  state)

Initializes a new instance of the T:System.Security.PermissionSet class with the specified T:System.Security.Permissions.PermissionState.

Parameters
stateOne of the enumeration values that specifies the permission set's access to resources.
Exceptions
T:System.ArgumentExceptionThe state parameter is not a valid T:System.Security.Permissions.PermissionState.

Definition at line 202 of file PermissionSet.cs.

◆ PermissionSet() [2/2]

System.Security.PermissionSet.PermissionSet ( PermissionSet  permSet)

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

Parameters
permSetThe set from which to take the value of the new T:System.Security.PermissionSet, or null to create an empty T:System.Security.PermissionSet.

Definition at line 220 of file PermissionSet.cs.

Member Function Documentation

◆ AddPermission()

IPermission System.Security.PermissionSet.AddPermission ( IPermission  perm)

Adds a specified permission to the T:System.Security.PermissionSet.

Parameters
permThe permission to add.
Returns
The union of the permission added and any permission of the same type that already exists in the T:System.Security.PermissionSet.
Exceptions
T:System.InvalidOperationExceptionThe method is called from a T:System.Security.ReadOnlyPermissionSet.

Definition at line 433 of file PermissionSet.cs.

◆ AddPermissionImpl()

virtual IPermission System.Security.PermissionSet.AddPermissionImpl ( IPermission  perm)
protectedvirtual

Adds a specified permission to the T:System.Security.PermissionSet.

Parameters
permThe permission to add.
Returns
The union of the permission added and any permission of the same type that already exists in the T:System.Security.PermissionSet, or null if perm is null.
Exceptions
T:System.InvalidOperationExceptionThe method is called from a T:System.Security.ReadOnlyPermissionSet.

Reimplemented in System.Security.ReadOnlyPermissionSet.

Definition at line 442 of file PermissionSet.cs.

◆ Assert()

void System.Security.PermissionSet.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 M:System.Security.PermissionSet.Assert can create security vulnerabilities.

Exceptions
T:System.Security.SecurityExceptionThe T:System.Security.PermissionSet instance asserted has not been granted to the asserting code.-or- There is already an active M:System.Security.PermissionSet.Assert for the current frame.

Implements System.Security.IStackWalk.

Definition at line 1365 of file PermissionSet.cs.

◆ ContainsNonCodeAccessPermissions()

bool System.Security.PermissionSet.ContainsNonCodeAccessPermissions ( )

Gets a value indicating whether the T:System.Security.PermissionSet contains permissions that are not derived from T:System.Security.CodeAccessPermission.

Returns
true if the T:System.Security.PermissionSet contains permissions that are not derived from T:System.Security.CodeAccessPermission; otherwise, false.

Definition at line 1942 of file PermissionSet.cs.

◆ ConvertPermissionSet()

static byte [] System.Security.PermissionSet.ConvertPermissionSet ( string  inFormat,
byte []  inData,
string  outFormat 
)
static

Converts an encoded T:System.Security.PermissionSet from one XML encoding format to another XML encoding format.

Parameters
inFormatA string representing one of the following encoding formats: ASCII, Unicode, or Binary. Possible values are "XMLASCII" or "XML", "XMLUNICODE", and "BINARY".
inDataAn XML-encoded permission set.
outFormatA string representing one of the following encoding formats: ASCII, Unicode, or Binary. Possible values are "XMLASCII" or "XML", "XMLUNICODE", and "BINARY".
Returns
An encrypted permission set with the specified output format.
Exceptions
T:System.NotImplementedExceptionIn all cases.

Definition at line 1934 of file PermissionSet.cs.

◆ Copy()

virtual PermissionSet System.Security.PermissionSet.Copy ( )
virtual

Creates a copy of the T:System.Security.PermissionSet.

Returns
A copy of the T:System.Security.PermissionSet.

Reimplemented in System.Security.NamedPermissionSet, and System.Security.ReadOnlyPermissionSet.

Definition at line 1403 of file PermissionSet.cs.

◆ CopyTo()

virtual void System.Security.PermissionSet.CopyTo ( Array  array,
int  index 
)
virtual

Copies the permission objects of the set to the indicated location in an T:System.Array.

Parameters
arrayThe target array to which to copy.
indexThe starting position in the array to begin copying (zero based).
Exceptions
T:System.ArgumentNullExceptionThe array parameter is null.
T:System.ArgumentExceptionThe array parameter has more than one dimension.
T:System.IndexOutOfRangeExceptionThe index parameter is out of the range of the array parameter.

Implements System.Collections.ICollection.

Definition at line 260 of file PermissionSet.cs.

◆ Demand()

void System.Security.PermissionSet.Demand ( )

Forces a 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.

Exceptions
T:System.Security.SecurityExceptionA caller in the call chain does not have the permission demanded.

Implements System.Security.IStackWalk.

Definition at line 1325 of file PermissionSet.cs.

◆ Deny()

void System.Security.PermissionSet.Deny ( )

Causes any 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 T:System.Security.PermissionSet to fail.

Exceptions
T:System.Security.SecurityExceptionA previous call to M:System.Security.PermissionSet.Deny has already restricted the permissions for the current stack frame.

Implements System.Security.IStackWalk.

Definition at line 1376 of file PermissionSet.cs.

◆ Equals()

override bool System.Security.PermissionSet.Equals ( object  obj)

Determines whether the specified T:System.Security.PermissionSet or T:System.Security.NamedPermissionSet object is equal to the current T:System.Security.PermissionSet.

Parameters
objThe object to compare with the current T:System.Security.PermissionSet.
Returns
true if the specified object is equal to the current T:System.Security.PermissionSet object; otherwise, false.

Definition at line 1253 of file PermissionSet.cs.

◆ FromXml()

virtual void System.Security.PermissionSet.FromXml ( SecurityElement  et)
virtual

Reconstructs a security object with a specified state from an XML encoding.

Parameters
etThe XML encoding to use to reconstruct the security object.
Exceptions
T:System.ArgumentNullExceptionThe et parameter is null.
T:System.ArgumentExceptionThe et parameter is not a valid permission element.-or- The et parameter's version number is not supported.

Implements System.Security.ISecurityEncodable.

Reimplemented in System.Security.NamedPermissionSet, and System.Security.ReadOnlyPermissionSet.

Definition at line 1517 of file PermissionSet.cs.

◆ GetEnumerator()

IEnumerator System.Security.PermissionSet.GetEnumerator ( )

Returns an enumerator for the permissions of the set.

Returns
An enumerator object for the permissions of the set.

Implements System.Collections.IEnumerable.

Definition at line 1421 of file PermissionSet.cs.

◆ GetEnumeratorImpl()

virtual IEnumerator System.Security.PermissionSet.GetEnumeratorImpl ( )
protectedvirtual

Returns an enumerator for the permissions of the set.

Returns
An enumerator object for the permissions of the set.

Reimplemented in System.Security.ReadOnlyPermissionSet.

Definition at line 1428 of file PermissionSet.cs.

◆ GetHashCode()

override int System.Security.PermissionSet.GetHashCode ( )

Gets a hash code for the 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 T:System.Security.PermissionSet object.

Definition at line 1302 of file PermissionSet.cs.

◆ GetPermission()

IPermission System.Security.PermissionSet.GetPermission ( Type  permClass)

Gets a permission object of the specified type, if it exists in the set.

Parameters
permClassThe type of the desired permission object.
Returns
A copy of the permission object of the type specified by the permClass parameter contained in the T:System.Security.PermissionSet, or null if none exists.

Definition at line 381 of file PermissionSet.cs.

◆ GetPermissionImpl()

virtual IPermission System.Security.PermissionSet.GetPermissionImpl ( Type  permClass)
protectedvirtual

Gets a permission object of the specified type, if it exists in the set.

Parameters
permClassThe type of the permission object.
Returns
A copy of the permission object, of the type specified by the permClass parameter, contained in the T:System.Security.PermissionSet, or null if none exists.

Reimplemented in System.Security.ReadOnlyPermissionSet.

Definition at line 389 of file PermissionSet.cs.

◆ Intersect()

PermissionSet System.Security.PermissionSet.Intersect ( PermissionSet  other)

Creates and returns a permission set that is the intersection of the current T:System.Security.PermissionSet and the specified T:System.Security.PermissionSet.

Parameters
otherA permission set to intersect with the current T:System.Security.PermissionSet.
Returns
A new permission set that represents the intersection of the current T:System.Security.PermissionSet and the specified target. This object is null if the intersection is empty.

Definition at line 879 of file PermissionSet.cs.

◆ IsEmpty()

bool System.Security.PermissionSet.IsEmpty ( )

Gets a value indicating whether the T:System.Security.PermissionSet is empty.

Returns
true if the T:System.Security.PermissionSet is empty; otherwise, false.

Definition at line 301 of file PermissionSet.cs.

◆ IsSubsetOf()

bool System.Security.PermissionSet.IsSubsetOf ( PermissionSet  target)

Determines whether the current T:System.Security.PermissionSet is a subset of the specified T:System.Security.PermissionSet.

Parameters
targetThe permission set to test for the subset relationship. This must be either a T:System.Security.PermissionSet or a T:System.Security.NamedPermissionSet.
Returns
true if the current T:System.Security.PermissionSet is a subset of the target parameter; otherwise, false.

Definition at line 604 of file PermissionSet.cs.

◆ IsUnrestricted()

bool System.Security.PermissionSet.IsUnrestricted ( )

Determines whether the T:System.Security.PermissionSet is Unrestricted.

Returns
true if the T:System.Security.PermissionSet is Unrestricted; otherwise, false.

Definition at line 519 of file PermissionSet.cs.

◆ PermitOnly()

void System.Security.PermissionSet.PermitOnly ( )

Causes any M:System.Security.PermissionSet.Demand that passes through the calling code for any T:System.Security.PermissionSet that is not a subset of the current T:System.Security.PermissionSet to fail.

Implements System.Security.IStackWalk.

Definition at line 1385 of file PermissionSet.cs.

◆ RemovePermission()

IPermission System.Security.PermissionSet.RemovePermission ( Type  permClass)

Removes a permission of a certain type from the set.

Parameters
permClassThe type of permission to delete.
Returns
The permission removed from the set.
Exceptions
T:System.InvalidOperationExceptionThe method is called from a T:System.Security.ReadOnlyPermissionSet.

Definition at line 484 of file PermissionSet.cs.

◆ RemovePermissionImpl()

virtual IPermission System.Security.PermissionSet.RemovePermissionImpl ( Type  permClass)
protectedvirtual

Removes a permission of a certain type from the set.

Parameters
permClassThe type of the permission to remove.
Returns
The permission removed from the set.
Exceptions
T:System.InvalidOperationExceptionThe method is called from a T:System.Security.ReadOnlyPermissionSet.

Reimplemented in System.Security.ReadOnlyPermissionSet.

Definition at line 493 of file PermissionSet.cs.

◆ RevertAssert()

static void System.Security.PermissionSet.RevertAssert ( )
static

Causes any previous M:System.Security.CodeAccessPermission.Assert for the current frame to be removed and no longer be in effect.

Exceptions
T:System.InvalidOperationExceptionThere is no previous M:System.Security.CodeAccessPermission.Assert for the current frame.

Definition at line 2147 of file PermissionSet.cs.

◆ SetPermission()

IPermission System.Security.PermissionSet.SetPermission ( IPermission  perm)

Sets a permission to the T:System.Security.PermissionSet, replacing any existing permission of the same type.

Parameters
permThe permission to set.
Returns
The set permission.
Exceptions
T:System.InvalidOperationExceptionThe method is called from a T:System.Security.ReadOnlyPermissionSet.

Definition at line 402 of file PermissionSet.cs.

◆ SetPermissionImpl()

virtual IPermission System.Security.PermissionSet.SetPermissionImpl ( IPermission  perm)
protectedvirtual

Sets a permission to the T:System.Security.PermissionSet, replacing any existing permission of the same type.

Parameters
permThe permission to set.
Returns
The set permission.
Exceptions
T:System.InvalidOperationExceptionThe method is called from a T:System.Security.ReadOnlyPermissionSet.

Reimplemented in System.Security.ReadOnlyPermissionSet.

Definition at line 411 of file PermissionSet.cs.

◆ ToString()

override string System.Security.PermissionSet.ToString ( )

Returns a string representation of the T:System.Security.PermissionSet.

Returns
A representation of the T:System.Security.PermissionSet.

Definition at line 1440 of file PermissionSet.cs.

◆ ToXml()

virtual SecurityElement System.Security.PermissionSet.ToXml ( )
virtual

Creates an XML encoding of the security object and its current state.

Returns
An XML encoding of the security object, including any state information.

Implements System.Security.ISecurityEncodable.

Reimplemented in System.Security.NamedPermissionSet, and System.Security.ReadOnlyPermissionSet.

Definition at line 1909 of file PermissionSet.cs.

◆ Union()

PermissionSet System.Security.PermissionSet.Union ( PermissionSet  other)

Creates a T:System.Security.PermissionSet that is the union of the current T:System.Security.PermissionSet and the specified T:System.Security.PermissionSet.

Parameters
otherThe permission set to form the union with the current T:System.Security.PermissionSet.
Returns
A new permission set that represents the union of the current T:System.Security.PermissionSet and the specified T:System.Security.PermissionSet.

Definition at line 1101 of file PermissionSet.cs.

Member Data Documentation

◆ IsReadOnly

virtual bool System.Security.PermissionSet.IsReadOnly => false

Gets a value indicating whether the collection is read-only.

Returns
Always false.

Definition at line 93 of file PermissionSet.cs.

◆ IsSynchronized

virtual bool System.Security.PermissionSet.IsSynchronized => false

Gets a value indicating whether the collection is guaranteed to be thread safe.

Returns
Always false.

Definition at line 89 of file PermissionSet.cs.

◆ SyncRoot

virtual object System.Security.PermissionSet.SyncRoot => this

Gets the root object of the current collection.

Returns
The root object of the current collection.

Definition at line 85 of file PermissionSet.cs.

Property Documentation

◆ Count

virtual int System.Security.PermissionSet.Count
get

Gets the number of permission objects contained in the permission set.

Returns
The number of permission objects contained in the T:System.Security.PermissionSet.

Definition at line 98 of file PermissionSet.cs.


The documentation for this class was generated from the following file: