MethodBuilder.SetImplementationFlags(MethodImplAttributes) Yöntem

Tanım

Bu yöntem için uygulama bayraklarını ayarlar.

public:
 void SetImplementationFlags(System::Reflection::MethodImplAttributes attributes);
public void SetImplementationFlags(System.Reflection.MethodImplAttributes attributes);
member this.SetImplementationFlags : System.Reflection.MethodImplAttributes -> unit
Public Sub SetImplementationFlags (attributes As MethodImplAttributes)

Parametreler

attributes
MethodImplAttributes

Ayarlanacağı uygulama bayrakları.

Özel durumlar

İçeren tür daha önce kullanılarak CreateType()oluşturulmuştur.

-veya-

Geçerli yöntem IsGenericMethod için özelliği şeklindedir true, ancak IsGenericMethodDefinition özelliği şeklindedir false.

Örnekler

Aşağıdaki kod örneği, bir yöntem gövdesinde SetImplementationFlags MSIL uygulamasını açıklamak için yönteminin bağlamsal kullanımını gösterir.

MethodBuilder myMthdBuilder = myTypeBuilder.DefineMethod("MyMethod",
                    MethodAttributes.Public,
                    CallingConventions.HasThis,
                    typeof(int),
                    new Type[] { typeof(int),
                             typeof(int) });	

// Specifies that the dynamic method declared above has a an MSIL implementation,
    // is managed, synchronized (single-threaded) through the body, and that it
// cannot be inlined.

myMthdBuilder.SetImplementationFlags(MethodImplAttributes.IL |
                     MethodImplAttributes.Managed |
                     MethodImplAttributes.Synchronized |
                     MethodImplAttributes.NoInlining);

// Create an ILGenerator for the MethodBuilder and emit MSIL here ...
Dim myMthdBuilder As MethodBuilder = myTypeBuilder.DefineMethod("MyMethod", _
                 MethodAttributes.Public, _
                 CallingConventions.HasThis, _
                 GetType(Integer), _
                 New Type() {GetType(Integer), GetType(Integer)})

' Specifies that the dynamic method declared above has a an MSIL implementation,
' is managed, synchronized (single-threaded) through the body, and that it 
' cannot be inlined.

myMthdBuilder.SetImplementationFlags((MethodImplAttributes.IL Or _
                  MethodImplAttributes.Managed Or _
                  MethodImplAttributes.Synchronized Or _
                  MethodImplAttributes.NoInlining))

' Create an ILGenerator for the MethodBuilder and emit MSIL here ...

Açıklamalar

yöntemini yöntemiyle SetCustomAttribute birlikte kullandığınızda SetImplementationFlags olası etkileşimlere dikkat edin. Örneğin, SetCustomAttribute özniteliğini eklemek DllImportAttribute için yöntemini kullanmak bayrağını MethodImplAttributes.PreserveSig da ayarlar. Daha sonra yöntemini çağırırsanız SetImplementationFlags bayrağın PreserveSig üzerine yazılır. Bunu önlemenin iki yolu vardır:

Şunlara uygulanır