CallingConventions Sabit listesi

Tanım

Bir yöntem için geçerli çağırma kurallarını tanımlar.

Bu sabit listesi, üyeleri için bit düzeyinde karşılaştırmayı destekler.

public enum class CallingConventions
[System.Flags]
public enum CallingConventions
[System.Flags]
[System.Serializable]
public enum CallingConventions
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum CallingConventions
[<System.Flags>]
type CallingConventions = 
[<System.Flags>]
[<System.Serializable>]
type CallingConventions = 
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type CallingConventions = 
Public Enum CallingConventions
Devralma
CallingConventions
Öznitelikler

Alanlar

Any 3

Standard veya çağırma kuralının VarArgs kullanılabileceğini belirtir.

ExplicitThis 64

İmzanın, bir örneğe veya sanal yönteme (statik yöntem değil) yapılan çağrıyı temsil eden bir işlev işaretçisi imzası olduğunu belirtir. ayarlandıysa ExplicitThis , HasThis aynı zamanda ayarlanmalıdır. Çağrılan yönteme geçirilen ilk bağımsız değişken hala bir this işaretçidir, ancak ilk bağımsız değişkenin türü artık bilinmemektedir. Bu nedenle, işaretçinin türünü (veya sınıfını) this açıklayan bir belirteç açıkça meta veri imzasına depolanır.

HasThis 32

Bir örneği veya sanal yöntemi belirtir (statik bir yöntem değil). Çalışma zamanında, çağrılan yöntem hedef nesneye ilk bağımsız değişkeni ( this işaretçi) olarak bir işaretçi geçirilir. Meta verilerde depolanan imza bu ilk bağımsız değişkenin türünü içermez, çünkü yöntem bilinir ve meta verilerden sahip sınıfı bulunabilir.

Standard 1

Ortak dil çalışma zamanı tarafından belirlenen varsayılan çağırma kuralını belirtir. Statik yöntemler için bu çağırma kuralını kullanın. Örneğin veya sanal yöntemler için kullanın HasThis.

VarArgs 2

Değişken bağımsız değişkenleri olan yöntemler için çağırma kuralını belirtir.

Örnekler

using namespace System;
using namespace System::Reflection;
using namespace System::Security;
public ref class MyClass1
{
public:
   MyClass1( int i ){}

};

int main()
{
   try
   {
      Type^ myType = MyClass1::typeid;
      array<Type^>^types = gcnew array<Type^>(1);
      types[ 0 ] = int::typeid;
      
      // Get the public instance constructor that takes an integer parameter.
      ConstructorInfo^ constructorInfoObj = myType->GetConstructor( static_cast<BindingFlags>(BindingFlags::Instance | BindingFlags::Public), nullptr, CallingConventions::HasThis, types, nullptr );
      if ( constructorInfoObj != nullptr )
      {
         Console::WriteLine( "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is: " );
         Console::WriteLine( constructorInfoObj );
      }
      else
      {
         Console::WriteLine( "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is not available." );
      }
   }
   catch ( ArgumentNullException^ e ) 
   {
      Console::WriteLine( "ArgumentNullException: {0}", e->Message );
   }
   catch ( ArgumentException^ e ) 
   {
      Console::WriteLine( "ArgumentException: {0}", e->Message );
   }
   catch ( SecurityException^ e ) 
   {
      Console::WriteLine( "SecurityException: {0}", e->Message );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception: {0}", e->Message );
   }
}
using System;
using System.Reflection;
using System.Security;

public class MyClass1
{
    public MyClass1(int i){}
    public static void Main()
    {
        try
        {
            Type  myType = typeof(MyClass1);
            Type[] types = new Type[1];
            types[0] = typeof(int);
            // Get the public instance constructor that takes an integer parameter.
            ConstructorInfo constructorInfoObj = myType.GetConstructor(
                BindingFlags.Instance | BindingFlags.Public, null,
                CallingConventions.HasThis, types, null);
            if(constructorInfoObj != null)
            {
                Console.WriteLine("The constructor of MyClass1 that is a public " +
                    "instance method and takes an integer as a parameter is: ");
                Console.WriteLine(constructorInfoObj.ToString());
            }
            else
            {
                Console.WriteLine("The constructor of MyClass1 that is a public instance " +
                    "method and takes an integer as a parameter is not available.");
            }
        }
        catch(ArgumentNullException e)
        {
            Console.WriteLine("ArgumentNullException: " + e.Message);
        }
        catch(ArgumentException e)
        {
            Console.WriteLine("ArgumentException: " + e.Message);
        }
        catch(SecurityException e)
        {
            Console.WriteLine("SecurityException: " + e.Message);
        }
        catch(Exception e)
        {
            Console.WriteLine("Exception: " + e.Message);
        }
    }
}
Public Class MyClass1
    Public Sub New(ByVal i As Integer)
    End Sub
    Public Shared Sub Main()
        Try
            Dim myType As Type = GetType(MyClass1)
            Dim types(0) As Type
            types(0) = GetType(Integer)
            ' Get the public instance constructor that takes an integer parameter.
            Dim constructorInfoObj As ConstructorInfo = _
                        myType.GetConstructor(BindingFlags.Instance Or _
                        BindingFlags.Public, Nothing, _
                        CallingConventions.HasThis, types, Nothing)
            If Not (constructorInfoObj Is Nothing) Then
                Console.WriteLine("The constructor of MyClass1 that " + _
                                  "is a public instance method and takes an " + _
                                  "integer as a parameter is: ")
                Console.WriteLine(constructorInfoObj.ToString())
            Else
                Console.WriteLine("The constructor MyClass1 that " + _
                                  "is a public instance method and takes an " + _
                                  "integer as a parameter is not available.")
            End If
        Catch e As ArgumentNullException
            Console.WriteLine("ArgumentNullException: " + e.Message)
        Catch e As ArgumentException
            Console.WriteLine("ArgumentException: " + e.Message)
        Catch e As SecurityException
            Console.WriteLine("SecurityException: " + e.Message)
        Catch e As Exception
            Console.WriteLine("Exception: " + e.Message)
        End Try
    End Sub
End Class

Açıklamalar

Yerel çağrı kuralı, derlenmiş yöntemlere geçirilen bağımsız değişkenlerin sırasını ve düzenini yöneten kurallar kümesidir. Ayrıca dönüş değerini geçirme, bağımsız değişkenler için kullanılacak kayıt sayısı ve çağrılan yöntemin veya çağıran yöntemin bağımsız değişkenleri yığından kaldırıp kaldırmadığını da yönetir.

Şunlara uygulanır