Freigeben über


ResourcePermissionBaseEntry Klasse

Definition

Achtung

Code Access Security is not supported or honored by the runtime.

Definiert die kleinste Einheit eines Berechtigungssatzes für die Codezugriffssicherheit.

public ref class ResourcePermissionBaseEntry
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public class ResourcePermissionBaseEntry
[System.Serializable]
public class ResourcePermissionBaseEntry
public class ResourcePermissionBaseEntry
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type ResourcePermissionBaseEntry = class
[<System.Serializable>]
type ResourcePermissionBaseEntry = class
type ResourcePermissionBaseEntry = class
Public Class ResourcePermissionBaseEntry
Vererbung
ResourcePermissionBaseEntry
Attribute

Beispiele

Das folgende Beispiel erbt von der ResourcePermissionBase -Klasse. Es werden vier Arten von Konstruktoren implementiert. Das Beispiel stellt auch eine Implementierung einer Klasse namens bereit MailslotPermissionEntry. Die PermissionAccessType -Eigenschaft wird dann privat auf den Typ von MailslotPermissionEntryfestgelegt. Die TagNames Eigenschaft wird privat auf "Name" und "Machine" festgelegt.

#using <System.dll>

using namespace System;
using namespace System::Security::Permissions;
using namespace System::Collections;

[Flags]

public enum class MailslotPermissionAccess
{
   None = 0,
   Send = 1 << 1,
   Receive = 1 << 2 | MailslotPermissionAccess::Send
};


[Serializable]
public ref class MailslotPermissionEntry
{
private:
   String^ name;
   String^ machineName;
   MailslotPermissionAccess permissionAccess;

internal:
   MailslotPermissionEntry( ResourcePermissionBaseEntry^ baseEntry )
   {
      this->permissionAccess = (MailslotPermissionAccess)baseEntry->PermissionAccess;
      this->name = baseEntry->PermissionAccessPath[ 0 ]->ToString();
      this->machineName = baseEntry->PermissionAccessPath[ 1 ]->ToString();
   }

   ResourcePermissionBaseEntry^ GetBaseEntry()
   {
      array<String^>^newStrings = {this->Name,this->MachineName};
      ResourcePermissionBaseEntry^ baseEntry = gcnew ResourcePermissionBaseEntry( (int)(this->PermissionAccess),newStrings );
      return baseEntry;
   }

public:
   MailslotPermissionEntry( MailslotPermissionAccess permissionAccess, String^ name, String^ machineName )
   {
      this->permissionAccess = permissionAccess;
      this->name = name;
      this->machineName = machineName;
   }

   property String^ Name 
   {
      String^ get()
      {
         return this->name;
      }
   }

   property String^ MachineName 
   {
      String^ get()
      {
         return this->machineName;
      }
   }

   property MailslotPermissionAccess PermissionAccess 
   {
      MailslotPermissionAccess get()
      {
         return this->permissionAccess;
      }
   }
};


[Serializable]
public ref class MailslotPermission: public ResourcePermissionBase
{
private:
   ArrayList^ innerCollection;
   void SetNames()
   {
      this->PermissionAccessType = MailslotPermissionAccess::typeid;
      array<String^>^newStrings = {"Name","Machine"};
      this->TagNames = newStrings;
   }


internal:
   void AddPermissionAccess( MailslotPermissionEntry^ entry )
   {
      ResourcePermissionBase::AddPermissionAccess( entry->GetBaseEntry() );
   }

   void Clear()
   {
      ResourcePermissionBase::Clear();
   }

   void RemovePermissionAccess( MailslotPermissionEntry^ entry )
   {
      ResourcePermissionBase::RemovePermissionAccess( entry->GetBaseEntry() );
   }


public:
   MailslotPermission()
   {
      SetNames();
   }

   MailslotPermission( PermissionState state )
      : ResourcePermissionBase( state )
   {
      SetNames();
   }

   MailslotPermission( MailslotPermissionAccess permissionAccess, String^ name, String^ machineName )
   {
      SetNames();
      this->AddPermissionAccess( gcnew MailslotPermissionEntry( permissionAccess,name,machineName ) );
   }

   MailslotPermission( array<MailslotPermissionEntry^>^permissionAccessEntries )
   {
      SetNames();
      if ( permissionAccessEntries == nullptr )
            throw gcnew ArgumentNullException( "permissionAccessEntries" );

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

   property ArrayList^ PermissionEntries 
   {
      ArrayList^ get()
      {
         if ( this->innerCollection == nullptr )
                  this->innerCollection = gcnew ArrayList;

         this->innerCollection->InsertRange( 0, safe_cast<ICollection^>(ResourcePermissionBase::GetPermissionEntries()) );
         return this->innerCollection;
      }
   }
};
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;
    }
}
Imports System.Security.Permissions
Imports System.Collections

<Serializable()> Public Class MailslotPermission
    Inherits ResourcePermissionBase

    Private innerCollection As ArrayList


    Public Sub New()
        SetNames()
    End Sub


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


    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


    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

    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


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


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


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

<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


    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


    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

Hinweise

Achtung

Die Codezugriffssicherheit (CAS, Code Access Security) ist in allen Versionen von .NET Framework und .NET veraltet. Aktuelle Versionen von .NET berücksichtigen keine CAS-Anmerkungen und erzeugen Fehler, wenn CAS-bezogene APIs verwendet werden. Entwickler*innen sollten alternative Mittel zum Ausführen von Sicherheitsaufgaben suchen.

Konstruktoren

ResourcePermissionBaseEntry()
Veraltet.

Initialisiert eine neue Instanz der ResourcePermissionBaseEntry-Klasse.

ResourcePermissionBaseEntry(Int32, String[])
Veraltet.

Initialisiert eine neue Instanz der ResourcePermissionBaseEntry-Klasse mit dem angegebenen Berechtigungszugriff und Berechtigungszugriffspfad.

Eigenschaften

PermissionAccess
Veraltet.

Ruft eine Ganzzahldarstellung des Enumerationswerts für die Zugriffsebene ab.

PermissionAccessPath
Veraltet.

Ruft ein Array von Zeichenfolgen ab, die die geschützte Ressource bezeichnen.

Methoden

Equals(Object)
Veraltet.

Bestimmt, ob das angegebene Objekt gleich dem aktuellen Objekt ist.

(Geerbt von Object)
GetHashCode()
Veraltet.

Fungiert als Standardhashfunktion.

(Geerbt von Object)
GetType()
Veraltet.

Ruft den Type der aktuellen Instanz ab.

(Geerbt von Object)
MemberwiseClone()
Veraltet.

Erstellt eine flache Kopie des aktuellen Object.

(Geerbt von Object)
ToString()
Veraltet.

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.

(Geerbt von Object)

Gilt für: