ConstructorBuilder.GetModule Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mengembalikan referensi ke modul yang berisi konstruktor ini.
public:
System::Reflection::Module ^ GetModule();
public System.Reflection.Module GetModule ();
member this.GetModule : unit -> System.Reflection.Module
Public Function GetModule () As Module
Mengembalikan
Modul yang berisi konstruktor ini.
Keterangan
Sampel kode berikut mengilustrasikan penggunaan GetModule
.
ModuleBuilder^ myModBuilder = myAsmBuilder->DefineDynamicModule( "MathFunctions" );
TypeBuilder^ myTypeBuilder = myModBuilder->DefineType( "MyMathFunctions", TypeAttributes::Public );
array<Type^>^temp0 = {int::typeid,int::typeid};
MethodBuilder^ myMthdBuilder = myTypeBuilder->DefineMethod( "Adder", MethodAttributes::Public, int::typeid, temp0 );
// Create body via ILGenerator here ...
Type^ myNewType = myTypeBuilder->CreateType();
Module^ myModule = myMthdBuilder->GetModule();
array<Type^>^myModTypes = myModule->GetTypes();
Console::WriteLine( "Module: {0}", myModule->Name );
Console::WriteLine( "------- with path {0}", myModule->FullyQualifiedName );
Console::WriteLine( "------- in assembly {0}", myModule->Assembly->FullName );
System::Collections::IEnumerator^ myEnum = myModTypes->GetEnumerator();
while ( myEnum->MoveNext() )
{
Type^ myModType = safe_cast<Type^>(myEnum->Current);
Console::WriteLine( "------- has type {0}", myModType->FullName );
}
}
};
ModuleBuilder myModBuilder = myAsmBuilder.DefineDynamicModule("MathFunctions");
TypeBuilder myTypeBuilder = myModBuilder.DefineType("MyMathFunctions",
TypeAttributes.Public);
MethodBuilder myMthdBuilder = myTypeBuilder.DefineMethod("Adder",
MethodAttributes.Public,
typeof(int),
new Type[] { typeof(int),
typeof(int) });
// Create body via ILGenerator here ...
Type myNewType = myTypeBuilder.CreateType();
Module myModule = myMthdBuilder.GetModule();
Type[] myModTypes = myModule.GetTypes();
Console.WriteLine("Module: {0}", myModule.Name);
Console.WriteLine("------- with path {0}", myModule.FullyQualifiedName);
Console.WriteLine("------- in assembly {0}", myModule.Assembly.FullName);
foreach (Type myModType in myModTypes)
{
Console.WriteLine("------- has type {0}", myModType.FullName);
}
Dim myModBuilder As ModuleBuilder = myAsmBuilder.DefineDynamicModule("MathFunctions")
Dim myTypeBuilder As TypeBuilder = myModBuilder.DefineType("MyMathFunctions", _
TypeAttributes.Public)
Dim myMthdBuilder As MethodBuilder = myTypeBuilder.DefineMethod("Adder", _
MethodAttributes.Public, GetType(Integer), _
New Type() {GetType(Integer), GetType(Integer)})
' Create body via ILGenerator here ...
Dim myNewType As Type = myTypeBuilder.CreateType()
Dim myModule As [Module] = myMthdBuilder.GetModule()
Dim myModTypes As Type() = myModule.GetTypes()
Console.WriteLine("Module: {0}", myModule.Name)
Console.WriteLine("------- with path {0}", myModule.FullyQualifiedName)
Console.WriteLine("------- in assembly {0}", myModule.Assembly.FullName)
Dim myModType As Type
For Each myModType In myModTypes
Console.WriteLine("------- has type {0}", myModType.FullName)
Next myModType
Berlaku untuk
Berkolaborasi dengan kami di GitHub
Sumber untuk konten ini dapat ditemukan di GitHub, yang juga dapat Anda gunakan untuk membuat dan meninjau masalah dan menarik permintaan. Untuk informasi selengkapnya, lihat panduan kontributor kami.