ResourcePermissionBaseEntry Class

Defines the smallest unit of a code access security permission set.

System.Object
  System.Security.Permissions.ResourcePermissionBaseEntry

Namespace:  System.Security.Permissions
Assembly:  System (in System.dll)

[SerializableAttribute]
public class ResourcePermissionBaseEntry

The ResourcePermissionBaseEntry type exposes the following members.

  NameDescription
Public methodResourcePermissionBaseEntry()Initializes a new instance of the ResourcePermissionBaseEntry class.
Public methodResourcePermissionBaseEntry(Int32, String[])Initializes a new instance of the ResourcePermissionBaseEntry class with the specified permission access and permission access path.
Top

  NameDescription
Public propertyPermissionAccessGets an integer representation of the access level enumeration value.
Public propertyPermissionAccessPathGets an array of strings that identify the resource you are protecting.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The following example inherits from the ResourcePermissionBase class. 4 kinds of constructors are implemented. The example also provides an implementation of a class called MailslotPermissionEntry. The PermissionAccessType property is then privately set to the type of MailslotPermissionEntry. The TagNames property is set privately to "Name" and "Machine".


using System;        
using System.Security.Permissions;  
using System.Collections;

[Serializable()]
public class MailslotPermission: ResourcePermissionBase
{

	private ArrayList innerCollection;

	public MailslotPermission() 
	{
		SetNames();
	}                                                                

	public MailslotPermission(PermissionState state):base(state)
	{
		SetNames();
	}  

	public MailslotPermission(MailslotPermissionAccess permissionAccess, string name, string machineName)
	{
		SetNames();
		this.AddPermissionAccess(new MailslotPermissionEntry(permissionAccess, name, machineName));              
	}

	public MailslotPermission(MailslotPermissionEntry[] permissionAccessEntries) 
	{
		SetNames();
		if (permissionAccessEntries == null)
			throw new ArgumentNullException("permissionAccessEntries");

		for (int index = 0; index < permissionAccessEntries.Length; ++index)
			this.AddPermissionAccess(permissionAccessEntries[index]);                          
	}

	public ArrayList PermissionEntries 
	{
		get 
		{
			if (this.innerCollection == null)                     
				this.innerCollection = new ArrayList();
			this.innerCollection.InsertRange(0,base.GetPermissionEntries()); 

			return this.innerCollection;                                                               
		}
	}

	internal void AddPermissionAccess(MailslotPermissionEntry entry) 
	{
		base.AddPermissionAccess(entry.GetBaseEntry());
	}

	internal new void Clear() 
	{
		base.Clear();
	}

	internal void RemovePermissionAccess(MailslotPermissionEntry entry) 
	{
		base.RemovePermissionAccess(entry.GetBaseEntry());
	}

	private void SetNames() 
	{
		this.PermissionAccessType = typeof(MailslotPermissionAccess);
		this.TagNames = new string[]{"Name","Machine"};
	}                                
}

[Flags]         
public enum MailslotPermissionAccess 
{
	None = 0,
	Send = 1 << 1,
	Receive = 1 << 2 | Send,
} 

[Serializable()]     
public class MailslotPermissionEntry 
{
	private string name;
	private string machineName;
	private MailslotPermissionAccess permissionAccess;

	public MailslotPermissionEntry(MailslotPermissionAccess permissionAccess, string name, string machineName) 
	{
		this.permissionAccess = permissionAccess;
		this.name = name;
		this.machineName = machineName;
	}  

	internal MailslotPermissionEntry(ResourcePermissionBaseEntry baseEntry) 
	{
		this.permissionAccess = (MailslotPermissionAccess)baseEntry.PermissionAccess;
		this.name = baseEntry.PermissionAccessPath[0]; 
		this.machineName = baseEntry.PermissionAccessPath[1]; 
	}

	public string Name 
	{
		get 
		{                
			return this.name;                
		}                        
	}

	public string MachineName 
	{
		get 
		{                
			return this.machineName;                
		}                        
	}

	public MailslotPermissionAccess PermissionAccess 
	{
		get 
		{
			return this.permissionAccess;
		}                        
	}      

	internal ResourcePermissionBaseEntry GetBaseEntry() 
	{
		ResourcePermissionBaseEntry baseEntry = new ResourcePermissionBaseEntry((int)this.PermissionAccess, new string[] {this.Name,this.MachineName});            
		return baseEntry;
	}

}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft