This documentation is archived and is not being maintained.

ResourcePermissionBaseEntry Class

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

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

'Declaration
<SerializableAttribute> _
Public Class ResourcePermissionBaseEntry
'Usage
Dim instance As ResourcePermissionBaseEntry

/** @attribute SerializableAttribute() */ 
public class ResourcePermissionBaseEntry
SerializableAttribute 
public class ResourcePermissionBaseEntry

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".

Imports System
Imports System.Security.Permissions
Imports System.Collections

<Serializable()> Public Class MailslotPermission
    Inherits ResourcePermissionBase

    Private innerCollection As ArrayList


    Public Sub New()
        SetNames()
    End Sub 'New


    Public Sub New(ByVal state As PermissionState)
        MyBase.New(state)
        SetNames()
    End Sub 'New


    Public Sub New(ByVal permissionAccess As MailslotPermissionAccess, ByVal name As String, ByVal machineName1 As String)
        SetNames()
        Me.AddPermissionAccess(New MailslotPermissionEntry(permissionAccess, name, machineName1))
    End Sub 'New


    Public Sub New(ByVal permissionAccessEntries() As MailslotPermissionEntry)
        SetNames()
        If permissionAccessEntries Is Nothing Then
            Throw New ArgumentNullException("permissionAccessEntries")
        End If
        Dim index As Integer

        While index < permissionAccessEntries.Length
            Me.AddPermissionAccess(permissionAccessEntries(index))
        End While
    End Sub 'New 

    Public ReadOnly Property PermissionEntries() As ArrayList
        Get
            If Me.innerCollection Is Nothing Then
                Me.innerCollection = New ArrayList()
            End If
            Me.innerCollection.InsertRange(0, MyBase.GetPermissionEntries())

            Return Me.innerCollection
        End Get
    End Property


    Friend Overloads Sub AddPermissionAccess(ByVal entry As MailslotPermissionEntry)
        MyBase.AddPermissionAccess(entry.GetBaseEntry())
    End Sub 'AddPermissionAccess


    Friend Shadows Sub Clear()
        MyBase.Clear()
    End Sub 'Clear


    Friend Overloads Sub RemovePermissionAccess(ByVal entry As MailslotPermissionEntry)
        MyBase.RemovePermissionAccess(entry.GetBaseEntry())
    End Sub 'RemovePermissionAccess


    Private Sub SetNames()
        Me.PermissionAccessType = GetType(MailslotPermissionAccess)
        Me.TagNames = New String() {"Name", "Machine"}
    End Sub 'SetNames
End Class 'MailslotPermission

<Flags()> Public Enum MailslotPermissionAccess
    None = 0
    Send = 2
    Receive = 4 Or Send
End Enum 'MailslotPermissionAccess

<Serializable()> Public Class MailslotPermissionEntry
    Private nameVar As String
    Private machineNameVar As String
    Private permissionAccessVar As MailslotPermissionAccess


    Public Sub New(ByVal permissionAccess As MailslotPermissionAccess, ByVal name As String, ByVal machineName1 As String)
        Me.permissionAccessVar = permissionAccess
        Me.nameVar = name
        Me.machineNameVar = machineName1
    End Sub 'New


    Friend Sub New(ByVal baseEntry As ResourcePermissionBaseEntry)
        Me.permissionAccessVar = CType(baseEntry.PermissionAccess, MailslotPermissionAccess)
        Me.nameVar = baseEntry.PermissionAccessPath(0)
        Me.machineNameVar = baseEntry.PermissionAccessPath(1)
    End Sub 'New


    Public ReadOnly Property Name() As String
        Get
            Return Me.nameVar
        End Get
    End Property


    Public ReadOnly Property MachineName() As String
        Get
            Return Me.machineNameVar
        End Get
    End Property


    Public ReadOnly Property PermissionAccess() As MailslotPermissionAccess
        Get
            Return Me.permissionAccessVar
        End Get
    End Property


    Friend Function GetBaseEntry() As ResourcePermissionBaseEntry
        Dim baseEntry As New ResourcePermissionBaseEntry(CInt(Me.PermissionAccess), New String() {Me.Name, Me.MachineName})
        Return baseEntry
    End Function 'GetBaseEntry


End Class 'MailslotPermissionEntry

import System.*;
import System.Security.Permissions.*;
import System.Collections.*;

/** @attribute Serializable()
 */
public class MailSlotPermission extends ResourcePermissionBase
{   

    private ArrayList innerCollection;

    public MailSlotPermission()
    {
        SetNames();
    } //MailSlotPermission

    public MailSlotPermission(PermissionState state)
    {
      super(state);
      SetNames();
    } //MailSlotPermission

    public MailSlotPermission(MailSlotPermissionAccess permissionAccess, 
        String name, String machineName)
    {
        SetNames();
        this.AddPermissionAccess(new MailSlotPermissionEntry(permissionAccess,
            name, machineName));
    } //MailSlotPermission

    public MailSlotPermission(MailSlotPermissionEntry permissionAccessEntries[])
    {
        SetNames();
        if (permissionAccessEntries == null) {
            throw new ArgumentNullException("permissionAccessEntries");
        }

        for (int index = 0; index < permissionAccessEntries.get_Length(); 
            ++index) {
            this.AddPermissionAccess((MailSlotPermissionEntry)
                permissionAccessEntries.get_Item(index));
        }
    } //MailSlotPermission 

    /** @property 
     */
    public ArrayList get_PermissionEntries()
    {
        if (this.innerCollection == null) {
            this.innerCollection = new ArrayList();
        }
        this.innerCollection.InsertRange(0, super.GetPermissionEntries());
        return this.innerCollection;
    }

    void AddPermissionAccess(MailSlotPermissionEntry entry)
    {
        super.AddPermissionAccess(entry.GetBaseEntry());
    } //AddPermissionAccess

    public void Clear()
    {
        super.Clear();
    } //Clear

    void RemovePermissionAccess(MailSlotPermissionEntry entry)
    {
        super.RemovePermissionAccess(entry.GetBaseEntry());
    } //RemovePermissionAccess

    private void SetNames()
    {
        this.set_PermissionAccessType(MailSlotPermissionAccess.class.ToType());
        this.set_TagNames(new String[] { "Name", "Machine" });
    } //SetNames
} //MailSlotPermission

public class MailSlotPermissionAccess
{
    public static int None = 0;
    public static int Send = 1 << 1;
    public static int Receive = 1 << 2 | Send;
} //MailSlotPermissionAccess

/** @attribute 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;
    } //MailSlotPermissionEntry

    MailSlotPermissionEntry(ResourcePermissionBaseEntry baseEntry)
    {
        this.permissionAccess =(MailSlotPermissionAccess)(Object)((
            Int32)baseEntry.get_PermissionAccess());
        this.name = baseEntry.get_PermissionAccessPath()[0];
        this.machineName = baseEntry.get_PermissionAccessPath()[1];
    } //MailSlotPermissionEntry

    /** @property 
     */
    public String get_Name()
    {
        return this.name;
    }//get_Name

    /** @property
     */
    public String get_MachineName()
    {
        return this.machineName;
    }//get_MachineName

    /** @property
     */
    public MailSlotPermissionAccess get_PermissionAccess()
    {
        return this.permissionAccess;
    }//get_PermissionAccess

    ResourcePermissionBaseEntry GetBaseEntry()
    {
        ResourcePermissionBaseEntry baseEntry = new ResourcePermissionBaseEntry(
            Convert.ToInt32((Int32)((Object)(this.get_PermissionAccess()))), 
            new String[] { this.get_Name(), this.get_MachineName() });
        return baseEntry;
    } //GetBaseEntry
} //MailSlotPermissionEntry

System.Object
  System.Security.Permissions.ResourcePermissionBaseEntry

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: