CodeAccessPermission CodeAccessPermission CodeAccessPermission CodeAccessPermission Class

定義

定義所有程式碼存取權限的基礎結構。Defines the underlying structure of all code access permissions.

public ref class CodeAccessPermission abstract : System::Security::IPermission, System::Security::IStackWalk
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public abstract class CodeAccessPermission : System.Security.IPermission, System.Security.IStackWalk
type CodeAccessPermission = class
    interface IPermission
    interface ISecurityEncodable
    interface IStackWalk
Public MustInherit Class CodeAccessPermission
Implements IPermission, IStackWalk
繼承
CodeAccessPermissionCodeAccessPermissionCodeAccessPermissionCodeAccessPermission
衍生
屬性
實作

範例

下列程式碼範例示範衍生自的權限CodeAccessPermission類別。The following code example shows a permission derived from the CodeAccessPermission class.

//#define debug
// This custom permission is intended only for the purposes of illustration.
// The following code shows how to create a custom permission that inherits
// from CodeAccessPermission. The code implements all required overrides.
// A wildcard character ('*') is implemented for the Name property.

using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;
using namespace System::IO;
using namespace System::Security::Policy;
using namespace System::Collections;
using namespace System::Text;

[assembly:System::Reflection::AssemblyKeyFile("Key.snk")];
[assembly:System::Security::AllowPartiallyTrustedCallersAttribute];

[Serializable]
public ref class NameIdPermission: public CodeAccessPermission, public IUnrestrictedPermission
{
private:
   String^ m_Name;
   bool m_Unrestricted;

public:
   NameIdPermission( String^ name )
   {
      m_Name = name;
   }

   NameIdPermission( PermissionState state )
   {
      if ( state == PermissionState::None )
      {
         m_Name = "";
      }
      else if ( state == PermissionState::Unrestricted )
      {
         throw gcnew ArgumentException( "Unrestricted state is not allowed for identity permissions." );
      }
      else
      {
         throw gcnew ArgumentException( "Invalid permission state." );
      }
   }

   property String^ Name 
   {
      String^ get()
      {
         return m_Name;
      }
      void set( String^ value )
      {
         m_Name = value;
      }
   }

public:
   virtual IPermission^ Copy() override
   {
      String^ name = m_Name;
      return gcnew NameIdPermission( name );
   }

public:
   virtual bool IsUnrestricted()
   {
      // Always false, unrestricted state is not allowed.
      return m_Unrestricted;
   }

private:
   bool VerifyType( IPermission^ target )
   {
      return dynamic_cast<NameIdPermission^>(target) != nullptr;
   }

public:
   virtual bool IsSubsetOf( IPermission^ target ) override
   {
#if ( debug ) 
      Console::WriteLine( "************* Entering IsSubsetOf *********************" );
#endif

      if ( target == nullptr )
      {
         Console::WriteLine( "IsSubsetOf: target == null" );
         return false;
      }

#if ( debug ) 
      Console::WriteLine( "This is = {0}", ((NameIdPermission)this).Name );
      Console::WriteLine( "Target is {0}", ((NameIdPermission)target).m_Name );
#endif

      try
      {
         NameIdPermission^ operand = dynamic_cast<NameIdPermission^>(target);
         
         // The following check for unrestricted permission is only included as an example for
         // permissions that allow the unrestricted state. It is of no value for this permission.
         if ( true == operand->m_Unrestricted )
         {
            return true;
         }
         else if ( true == this->m_Unrestricted )
         {
            return false;
         }

         if ( this->m_Name != nullptr )
         {
            if ( operand->m_Name == nullptr )
            {
               return false;
            }
            if ( this->m_Name->Equals( "" ) )
            {
               return true;
            }
         }

         if ( this->m_Name->Equals( operand->m_Name ) )
         {
            return true;
         }
         else
         {
            // Check for wild card character '*'.
            int i = operand->m_Name->LastIndexOf( "*" );

            if ( i > 0 )
            {
               String^ prefix = operand->m_Name->Substring( 0, i );
               if ( this->m_Name->StartsWith( prefix ) )
               {
                  return true;
               }
            }
         }
         return false;
      }
      catch ( InvalidCastException^ ) 
      {
         throw gcnew ArgumentException( String::Format( "Argument_WrongType", this->GetType()->FullName ) );
      }
   }

public:
   virtual IPermission^ Intersect( IPermission^ target ) override
   {
      Console::WriteLine( "************* Entering Intersect *********************" );
      if ( target == nullptr )
      {
         return nullptr;
      }

#if ( debug ) 
      Console::WriteLine( "This is = {0}", ((NameIdPermission)this).Name );
      Console::WriteLine( "Target is {0}", ((NameIdPermission)target).m_Name );
#endif 

      if (  !VerifyType( target ) )
      {
         throw gcnew ArgumentException( String::Format( "Argument is wrong type.", this->GetType()->FullName ) );
      }

      NameIdPermission^ operand = dynamic_cast<NameIdPermission^>(target);

      if ( operand->IsSubsetOf( this ) )
      {
         return operand->Copy();
      }
      else if ( this->IsSubsetOf( operand ) )
      {
         return this->Copy();
      }
      else
      {
         return nullptr;
      }
   }

public:
   virtual IPermission^ Union( IPermission^ target ) override
   {
#if ( debug ) 
      Console::WriteLine( "************* Entering Union *********************" );
#endif 

      if ( target == nullptr )
      {
         return this;
      }

#if ( debug ) 
      Console::WriteLine( "This is = {0}", ((NameIdPermission)this).Name );
      Console::WriteLine( "Target is {0}", ((NameIdPermission)target).m_Name );
#endif 

      if (  !VerifyType( target ) )
      {
         throw gcnew ArgumentException( String::Format( "Argument_WrongType", this->GetType()->FullName ) );
      }

      NameIdPermission^ operand = dynamic_cast<NameIdPermission^>(target);

      if ( operand->IsSubsetOf( this ) )
      {
         return this->Copy();
      }
      else if ( this->IsSubsetOf( operand ) )
      {
         return operand->Copy();
      }
      else
      {
         return nullptr;
      }
   }

public:
   virtual void FromXml( SecurityElement^ e ) override
   {
      // The following code for unrestricted permission is only included as an example for
      // permissions that allow the unrestricted state. It is of no value for this permission.
      String^ elUnrestricted = e->Attribute("Unrestricted");
      if ( nullptr != elUnrestricted )
      {
         m_Unrestricted = Boolean::Parse( elUnrestricted );
         return;
      }

      String^ elName = e->Attribute("Name");
      m_Name = elName == nullptr ? nullptr : elName;
   }

public:
   virtual SecurityElement^ ToXml() override
   {
      // Use the SecurityElement class to encode the permission to XML.
      SecurityElement^ esd = gcnew SecurityElement( "IPermission" );
      String^ name = NameIdPermission::typeid->AssemblyQualifiedName;
      esd->AddAttribute( "class", name );
      esd->AddAttribute( "version", "1.0" );
      
      // The following code for unrestricted permission is only included as an example for
      // permissions that allow the unrestricted state. It is of no value for this permission.
      if ( m_Unrestricted )
      {
         esd->AddAttribute( "Unrestricted", true.ToString() );
      }

      if ( m_Name != nullptr )
      {
         esd->AddAttribute( "Name", m_Name );
      }

      return esd;
   }
};
//#define debug
// This custom permission is intended only for the purposes of illustration.
// The following code shows how to create a custom permission that inherits
// from CodeAccessPermission. The code implements all required overrides.
// A wildcard character ('*') is implemented for the Name property.
using System;
using System.Security;
using System.Security.Permissions;
using System.IO;
using System.Security.Policy;
using System.Collections;
using System.Text;

[assembly:System.Reflection.AssemblyKeyFile("Key.snk")]
[assembly:System.Security.AllowPartiallyTrustedCallersAttribute()]

namespace MyPermission
{
    [Serializable()] sealed public class   NameIdPermission : CodeAccessPermission, IUnrestrictedPermission
    {
        private String m_Name;
        private bool m_Unrestricted;

        public  NameIdPermission(String name)
        {
            m_Name = name;
        }

        public  NameIdPermission(PermissionState state)
        {
            if (state == PermissionState.None)
            {
                m_Name = "";
            }
            else
                if (state == PermissionState.Unrestricted)
            {
                throw new ArgumentException("Unrestricted state is not allowed for identity permissions.");
            }
            else throw new ArgumentException("Invalid permission state.");
        }

        public String Name
        {
            set{m_Name = value;}
            get{ return m_Name;}
        }
        public override IPermission Copy()
        {
            string name = m_Name;
            return new  NameIdPermission( name );
        }
        public bool IsUnrestricted()
        {
            // Always false, unrestricted state is not allowed.
            return m_Unrestricted;
        }

        private bool VerifyType(IPermission target)
        {
            return (target is  NameIdPermission);
        }
        public override bool IsSubsetOf(IPermission target)
        {
#if(debug)
            Console.WriteLine ("************* Entering IsSubsetOf *********************");
#endif
            if (target == null)
            {
                Console.WriteLine ("IsSubsetOf: target == null");
                return false;
            }
#if(debug)

            Console.WriteLine ("This is = " + (( NameIdPermission)this).Name);
            Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name);
#endif
            try
            {
                 NameIdPermission operand = ( NameIdPermission)target;

                // The following check for unrestricted permission is only included as an example for
                // permissions that allow the unrestricted state. It is of no value for this permission.
                if (true == operand.m_Unrestricted)
                {
                    return true;
                }
                else if (true == this.m_Unrestricted)
                {
                    return false;
                }

                if (this.m_Name != null)
                {
                    if (operand.m_Name == null) return false;

                    if (this.m_Name == "") return true;
                }

                if (this.m_Name.Equals (operand.m_Name)) return true;
                else
                {
                    // Check for wild card character '*'.
                    int i = operand.m_Name.LastIndexOf ("*");

                    if (i > 0)
                    {
                        string prefix = operand.m_Name.Substring (0, i);

                        if (this.m_Name.StartsWith (prefix))
                        {
                            return true;
                        }
                    }
                }

                return false;
            }
            catch (InvalidCastException)
            {
                throw new ArgumentException (String.Format ("Argument_WrongType", this.GetType ().FullName));
            }
        }
        public override IPermission Intersect(IPermission target)
        {
            Console.WriteLine ("************* Entering Intersect *********************");
            if (target == null)
            {
                return null;
            }
#if(debug)
            Console.WriteLine ("This is = " + (( NameIdPermission)this).Name);
            Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name);
#endif
            if (!VerifyType(target))
            {
                throw new ArgumentException (String.Format ("Argument is wrong type.", this.GetType ().FullName));
            }

             NameIdPermission operand = ( NameIdPermission)target;

            if (operand.IsSubsetOf (this)) return operand.Copy ();
            else if (this.IsSubsetOf (operand)) return this.Copy ();
            else
                return null;
        }

        public override IPermission Union(IPermission target)
        {
#if(debug)
            Console.WriteLine ("************* Entering Union *********************");
#endif
            if (target == null)
            {
                return this;
            }
#if(debug)
            Console.WriteLine ("This is = " + (( NameIdPermission)this).Name);
            Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name);
#endif
            if (!VerifyType(target))
            {
                throw new ArgumentException (String.Format ("Argument_WrongType", this.GetType ().FullName));
            }

             NameIdPermission operand = ( NameIdPermission)target;

            if (operand.IsSubsetOf (this)) return this.Copy ();
            else if (this.IsSubsetOf (operand)) return operand.Copy ();
            else
                return null;
        }
        
        
        
        
       public override void FromXml(SecurityElement e)
        {
            // The following code for unrestricted permission is only included as an example for
            // permissions that allow the unrestricted state. It is of no value for this permission.
            String elUnrestricted = e.Attribute("Unrestricted");
            if (null != elUnrestricted)
            {
                m_Unrestricted = bool.Parse(elUnrestricted);
                return;
            }

            String elName = e.Attribute( "Name" );
            m_Name = elName == null ? null : elName;
        }
        public override SecurityElement ToXml()
        {
            // Use the SecurityElement class to encode the permission to XML.
            SecurityElement esd = new SecurityElement("IPermission");
            String name = typeof( NameIdPermission).AssemblyQualifiedName;
            esd.AddAttribute("class", name);
            esd.AddAttribute("version", "1.0");

            // The following code for unrestricted permission is only included as an example for
            // permissions that allow the unrestricted state. It is of no value for this permission.
            if (m_Unrestricted)
            {
                esd.AddAttribute("Unrestricted", true.ToString());
            }
            if (m_Name != null) esd.AddAttribute( "Name", m_Name );
            return esd;
        }
     }
}
' This custom permission is intended only for the purposes of illustration.
' The following code shows how to create a custom permission that inherits
' from CodeAccessPermission. The code implements all required overrides.
' A wildcard character ('*') is implemented for the Name property.
Imports System
Imports System.Security
Imports System.Security.Permissions
Imports System.IO
Imports System.Security.Policy
Imports System.Collections
Imports Microsoft.VisualBasic

<assembly: System.Reflection.AssemblyKeyFile("Key.snk")>

<assembly: System.Security.AllowPartiallyTrustedCallersAttribute()>
Namespace MyPermission

    <Serializable()> _
                   Public NotInheritable Class NameIdPermission
        Inherits CodeAccessPermission
        Implements IUnrestrictedPermission
        Private m_Name As String
        Private m_Unrestricted As Boolean


        Public Sub New(ByVal name As String)
            m_name = name
        End Sub 'New


        Public Sub New(ByVal state As PermissionState)
            If state = PermissionState.None Then
                m_name = ""
            ElseIf state = PermissionState.Unrestricted Then
                Throw New ArgumentException("Unrestricted state is not allowed for identity permissions.")
            Else
                Throw New ArgumentException("Invalid permission state.")
            End If
        End Sub 'New 

        Public Property Name() As String
            Get
                Return m_name
            End Get
            Set(ByVal Value As String)
                m_name = Value
            End Set
        End Property

        Public Overrides Function Copy() As IPermission
            Dim name As String
            name = m_name
            Return New NameIdPermission(name)
        End Function 'Copy

        Public Function IsUnrestricted() As Boolean Implements IUnrestrictedPermission.IsUnrestricted
            ' Always false, unrestricted state is not allowed.
            Return m_Unrestricted
        End Function
        Private Function VerifyType(ByVal target As IPermission) As Boolean
            Return TypeOf target Is NameIdPermission
        End Function 'VerifyType

        Public Overrides Function IsSubsetOf(ByVal target As IPermission) As Boolean

#If (Debug) Then

            Console.WriteLine("************* Entering IsSubsetOf *********************")
#End If
            If target Is Nothing Then
                Console.WriteLine("IsSubsetOf: target == null")
                Return False
            End If
#If (Debug) Then
            Console.WriteLine(("This is = " + CType(Me, NameIdPermission).Name))
            Console.WriteLine(("Target is " + CType(target, NameIdPermission).m_name))
#End If
            Try
                Dim operand As NameIdPermission = CType(target, NameIdPermission)

                ' The following check for unrestricted permission is only included as an example for
                ' permissions that allow the unrestricted state. It is of no value for this permission.
                If True = operand.m_Unrestricted Then
                    Return True
                ElseIf True = Me.m_Unrestricted Then
                    Return False
                End If

                If Not (Me.m_name Is Nothing) Then
                    If operand.m_name Is Nothing Then
                        Return False
                    End If
                    If Me.m_name = "" Then
                        Return True
                    End If
                End If
                If Me.m_name.Equals(operand.m_name) Then
                    Return True
                Else
                    ' Check for wild card character '*'.
                    Dim i As Integer = operand.m_name.LastIndexOf("*")

                    If i > 0 Then
                        Dim prefix As String = operand.m_name.Substring(0, i)

                        If Me.m_name.StartsWith(prefix) Then
                            Return True
                        End If
                    End If
                End If

                Return False
            Catch
                Throw New ArgumentException(String.Format("Argument_WrongType", Me.GetType().FullName))
            End Try
        End Function

        Public Overrides Function Intersect(ByVal target As IPermission) As IPermission
            Console.WriteLine("************* Entering Intersect *********************")
            If target Is Nothing Then
                Return Nothing
            End If
#If (Debug) Then

            Console.WriteLine(("This is = " + CType(Me, NameIdPermission).Name))
            Console.WriteLine(("Target is " + CType(target, NameIdPermission).m_name))
#End If
            If Not VerifyType(target) Then
                Throw New ArgumentException(String.Format("Argument is wrong type.", Me.GetType().FullName))
            End If

            Dim operand As NameIdPermission = CType(target, NameIdPermission)

            If operand.IsSubsetOf(Me) Then
                Return operand.Copy()
            ElseIf Me.IsSubsetOf(operand) Then
                Return Me.Copy()
            Else
                Return Nothing
            End If
        End Function 'Intersect

        Public Overrides Function Union(ByVal target As IPermission) As IPermission
#If (Debug) Then

            Console.WriteLine("************* Entering Union *********************")
#End If
            If target Is Nothing Then
                Return Me
            End If
#If (Debug) Then
            Console.WriteLine(("This is = " + CType(Me, NameIdPermission).Name))
            Console.WriteLine(("Target is " + CType(target, NameIdPermission).m_name))
#End If
            If Not VerifyType(target) Then
                Throw New ArgumentException(String.Format("Argument_WrongType", Me.GetType().FullName))
            End If

            Dim operand As NameIdPermission = CType(target, NameIdPermission)

            If operand.IsSubsetOf(Me) Then
                Return Me.Copy()
            ElseIf Me.IsSubsetOf(operand) Then
                Return operand.Copy()
            Else
                Return Nothing
            End If
        End Function 'Union

        Public Overrides Sub FromXml(ByVal e As SecurityElement)
            ' The following code for unrestricted permission is only included as an example for
            ' permissions that allow the unrestricted state. It is of no value for this permission.
            Dim elUnrestricted As String = e.Attribute("Unrestricted")
            If Nothing <> elUnrestricted Then
                m_Unrestricted = Boolean.Parse(elUnrestricted)
                Return
            End If

            Dim elName As String = e.Attribute("Name")
            m_name = IIf(elName Is Nothing, Nothing, elName)
        End Sub 'FromXml

        Public Overrides Function ToXml() As SecurityElement
            ' Use the SecurityElement class to encode the permission to XML.
            Dim esd As New SecurityElement("IPermission")

            Dim name As String = GetType(NameIdPermission).AssemblyQualifiedName
            esd.AddAttribute("class", name)
            esd.AddAttribute("version", "1.0")

            ' The following code for unrestricted permission is only included as an example for
            ' permissions that allow the unrestricted state. It is of no value for this permission.
            If m_Unrestricted Then
                esd.AddAttribute("Unrestricted", True.ToString())
            End If
            If Not (m_Name Is Nothing) Then
                esd.AddAttribute("Name", m_Name)
            End If
            Return esd
        End Function 'ToXml
    End Class ' NameIdPermission 
End Namespace

備註

程式碼存取權限會使用堆疊查核行程,以確保所有的呼叫端程式碼必須被授與,權限。Code access permissions use a stack walk to ensure that all callers of the code have been granted a permission. 權限物件是否null,它會處理與狀態的使用權限物件相同PermissionState.NoneIf a permission object is null, it is handled the same as a permission object with the state PermissionState.None.

通常,向下成長,來表示呼叫堆疊,使方法呼叫堆疊中較高層呼叫方法較低的呼叫堆疊中。The call stack is typically represented as growing down, so that methods higher in the call stack call methods lower in the call stack.

繼承者CodeAccessPermission類別必須被授與完全信任才能正確運作,做為擴充的安全性基礎結構的權限。Inheritors of the CodeAccessPermission class must be granted full trust to function correctly as permissions extending the security infrastructure. 若要判斷是否完全信任,所以繼承者CodeAccessPermission問題InheritanceDemandfor ControlEvidence = trueControlPolicy = trueTo determine that the inheritors are fully trusted, CodeAccessPermission issues an InheritanceDemand for ControlEvidence = true and ControlPolicy = true.

給繼承者的注意事項

當您繼承自CodeAccessPermission,您也必須實作IUnrestrictedPermission介面。When you inherit from CodeAccessPermission, you must also implement the IUnrestrictedPermission interface.

下列CodeAccessPermission成員必須覆寫: Copy()Intersect(IPermission)IsSubsetOf(IPermission)ToXml()FromXml(SecurityElement),和Union(IPermission)The following CodeAccessPermission members must be overridden: Copy(), Intersect(IPermission), IsSubsetOf(IPermission), ToXml(), FromXml(SecurityElement), and Union(IPermission).

您也必須定義的建構函式PermissionState做為其唯一參數。You must also define a constructor that takes a PermissionState as its only parameter.

您必須套用SerializableAttribute屬性的類別,繼承自CodeAccessPermissionYou must apply the SerializableAttribute attribute to a class that inherits from CodeAccessPermission.

建構函式

CodeAccessPermission() CodeAccessPermission() CodeAccessPermission() CodeAccessPermission()

初始化 CodeAccessPermission 類別的新執行個體。Initializes a new instance of the CodeAccessPermission class.

方法

Assert() Assert() Assert() 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. 使用 Assert() 可能會造成安全性問題。Using Assert() can create security issues.

Copy() Copy() Copy() Copy()

由衍生類別實作時,建立並傳回目前權限物件的相同複本。When implemented by a derived class, creates and returns an identical copy of the current permission object.

Demand() Demand() Demand() Demand()

如果呼叫堆疊中所有較高層的呼叫端尚未授與目前執行個體 (Instance) 所指定的使用權限,請於執行階段強制執行 SecurityExceptionForces a SecurityException at run time if all callers higher in the call stack have not been granted the permission specified by the current instance.

Deny() Deny() Deny() Deny()

防止呼叫堆疊中較高層的呼叫端,使用呼叫這個方法的程式碼來存取目前執行個體所指定的資源。Prevents callers higher in the call stack from using the code that calls this method to access the resource specified by the current instance.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的 CodeAccessPermission 物件是否等於目前的 CodeAccessPermissionDetermines whether the specified CodeAccessPermission object is equal to the current CodeAccessPermission.

FromXml(SecurityElement) FromXml(SecurityElement) FromXml(SecurityElement) FromXml(SecurityElement)

在衍生類別中覆寫時,使用 XML 編碼方式重建具有指定狀態的安全性物件。When overridden in a derived class, reconstructs a security object with a specified state from an XML encoding.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

取得 CodeAccessPermission 物件的雜湊碼,其適合用於雜湊表這類的雜湊演算法和資料結構。Gets a hash code for the CodeAccessPermission object that is suitable for use in hashing algorithms and data structures such as a hash table.

GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
Intersect(IPermission) Intersect(IPermission) Intersect(IPermission) Intersect(IPermission)

當由衍生類別實作時,建立並傳回目前使用權限和指定使用權限交集的使用權限。When implemented by a derived class, creates and returns a permission that is the intersection of the current permission and the specified permission.

IsSubsetOf(IPermission) IsSubsetOf(IPermission) IsSubsetOf(IPermission) IsSubsetOf(IPermission)

當由衍生類別實作時,決定目前使用權限是否為指定使用權限的子集。When implemented by a derived class, determines whether the current permission is a subset of the specified permission.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
PermitOnly() PermitOnly() PermitOnly() PermitOnly()

防止呼叫堆疊中較高層的呼叫端,使用呼叫這個方法的程式碼來存取除了目前執行個體所指定資源之外的所有資源。Prevents callers higher in the call stack from using the code that calls this method to access all resources except for the resource specified by the current instance.

RevertAll() RevertAll() RevertAll() RevertAll()

造成目前框架先前的所有覆寫都被移除且不再發生作用Causes all previous overrides for the current frame to be removed and no longer in effect.

RevertAssert() RevertAssert() RevertAssert() RevertAssert()

造成目前框架任何先前的 Assert() 將移除並且不再有效。Causes any previous Assert() for the current frame to be removed and no longer in effect.

RevertDeny() RevertDeny() RevertDeny() RevertDeny()

造成目前框架任何先前的 Deny() 將移除並且不再有效。Causes any previous Deny() for the current frame to be removed and no longer in effect.

RevertPermitOnly() RevertPermitOnly() RevertPermitOnly() RevertPermitOnly()

造成目前框架任何先前的 PermitOnly() 將移除並且不再有效。Causes any previous PermitOnly() for the current frame to be removed and no longer in effect.

ToString() ToString() ToString() ToString()

建立並傳回目前使用權限物件的字串表示。Creates and returns a string representation of the current permission object.

ToXml() ToXml() ToXml() ToXml()

在衍生類別中覆寫時,建立安全性物件及其目前狀態的 XML 編碼。When overridden in a derived class, creates an XML encoding of the security object and its current state.

Union(IPermission) Union(IPermission) Union(IPermission) Union(IPermission)

在衍生類別中覆寫時,建立目前權限與指定權限聯集的權限。When overridden in a derived class, creates a permission that is the union of the current permission and the specified permission.

明確介面實作

IPermission.Demand() IPermission.Demand() IPermission.Demand() IPermission.Demand()
IStackWalk.Assert() IStackWalk.Assert() IStackWalk.Assert() IStackWalk.Assert()
IStackWalk.Demand() IStackWalk.Demand() IStackWalk.Demand() IStackWalk.Demand()
IStackWalk.Deny() IStackWalk.Deny() IStackWalk.Deny() IStackWalk.Deny()
IStackWalk.PermitOnly() IStackWalk.PermitOnly() IStackWalk.PermitOnly() IStackWalk.PermitOnly()

安全性

InheritanceDemand
繼承者提供的辨識項,並檢視和修改原則的能力。for the ability of inheritors to provide evidence and view and modify policy. 相關聯的列舉型別: ControlEvidenceControlPolicyAssociated enumerations: ControlEvidence, ControlPolicy.

適用於