MethodBuilder.SetImplementationFlags メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > MethodBuilder.SetImplementationFlags メソッドの意味・解説 

MethodBuilder.SetImplementationFlags メソッド

このメソッド実装フラグ設定します

名前空間: System.Reflection.Emit
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub SetImplementationFlags ( _
    attributes As MethodImplAttributes _
)
Dim instance As MethodBuilder
Dim attributes As MethodImplAttributes

instance.SetImplementationFlags(attributes)
public void SetImplementationFlags (
    MethodImplAttributes attributes
)
public:
void SetImplementationFlags (
    MethodImplAttributes attributes
)
public void SetImplementationFlags (
    MethodImplAttributes attributes
)
public function SetImplementationFlags (
    attributes : MethodImplAttributes
)

パラメータ

attributes

設定する実装フラグ

例外例外
例外種類条件

InvalidOperationException

外側の型が CreateType を使用して作成されています。

または

現在のメソッドでは、IsGenericMethod プロパティtrue ですが、IsGenericMethodDefinition プロパティfalse です。

解説解説

SetImplementationFlags メソッドを SetCustomAttribute メソッド組み合わせて使用する場合には、対話発生する可能性があることに注意してください。たとえば、SetCustomAttribute メソッド使用して DllImportAttribute 属性追加すると、MethodImplAttributes.PreserveSig フラグ設定されます。この後SetImplementationFlags メソッド呼び出すと、PreserveSig フラグ上書きされます。これを回避するには、次の 2 とおりの方法あります

使用例使用例

SetImplementationFlags メソッド使用してメソッド本体MSIL実装について指定する方法については、次のコード例参照してください

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

array<Type^>^ temp0 = { int::typeid, int::typeid
 };
MethodBuilder^ myMthdBuilder = myTypeBuilder->DefineMethod( "MyMethod"
,
                               MethodAttributes::Public,
                               CallingConventions::HasThis,
                               int::typeid,
                               temp0 );

// 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)(
                                        MethodImplAttributes::IL |
                                        MethodImplAttributes::Managed |
                                        MethodImplAttributes::Synchronized |
                                        MethodImplAttributes::NoInlining) );

// Create an ILGenerator for the MethodBuilder and emit MSIL here ...
MethodBuilder myMthdBuilder =
    myTypeBuilder.DefineMethod(
    "MyMethod", MethodAttributes.Public, CallingConventions.HasThis,
    int.class.ToType(), new
 Type[] { int.class.ToType(),
    int.class.ToType()});
// 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 ...
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MethodBuilder クラス
MethodBuilder メンバ
System.Reflection.Emit 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

MethodBuilder.SetImplementationFlags メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



MethodBuilder.SetImplementationFlags メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS