ModuleBuilder.DefineGlobalMethod Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Genel bir yöntem tanımlar.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| DefineGlobalMethod(String, MethodAttributes, Type, Type[]) |
Belirtilen ad, öznitelikler, dönüş türü ve parametre türleriyle genel bir yöntem tanımlar. |
| DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[]) |
Belirtilen ad, öznitelikler, çağırma kuralı, dönüş türü ve parametre türleri ile genel bir yöntem tanımlar. |
| DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type[], Type[], Type[][], Type[][]) |
Belirtilen ada, özniteliklere, çağırma kuralına, dönüş türüne, dönüş türüne yönelik özel değiştiricilere, parametre türlerine ve parametre türleri için özel değiştiricilere sahip genel bir yöntem tanımlar. |
DefineGlobalMethod(String, MethodAttributes, Type, Type[])
Belirtilen ad, öznitelikler, dönüş türü ve parametre türleriyle genel bir yöntem tanımlar.
public:
System::Reflection::Emit::MethodBuilder ^ DefineGlobalMethod(System::String ^ name, System::Reflection::MethodAttributes attributes, Type ^ returnType, cli::array <Type ^> ^ parameterTypes);
public System.Reflection.Emit.MethodBuilder DefineGlobalMethod(string name, System.Reflection.MethodAttributes attributes, Type returnType, Type[] parameterTypes);
member this.DefineGlobalMethod : string * System.Reflection.MethodAttributes * Type * Type[] -> System.Reflection.Emit.MethodBuilder
Public Function DefineGlobalMethod (name As String, attributes As MethodAttributes, returnType As Type, parameterTypes As Type()) As MethodBuilder
Parametreler
- name
- String
yönteminin adı.
name katıştırılmış null içeremez.
- attributes
- MethodAttributes
yönteminin öznitelikleri.
attributes içermelidir Static.
- returnType
- Type
yönteminin dönüş türü.
- parameterTypes
- Type[]
Yöntemin parametrelerinin türleri.
Döndürülenler
Tanımlanan genel yöntem.
Özel durumlar
Yöntemi statik değil. Yani, attributes içermez Static.
-veya-
Uzunluğu name sıfırdır
-veya-
Dizideki Type bir öğe şeklindedir null.
name, null'e eşittir.
CreateGlobalFunctions() daha önce çağrıldı.
Örnekler
Aşağıdaki örnek, geçerli ModuleBuilderöğesine bağlı tür bağımsız bir yöntem oluşturmak için öğesinin kullanımını DefineGlobalMethod gösterir. Genel yöntemi derledikten sonra tamamlamak CreateGlobalFunctions için çağrılmalıdır.
AppDomain currentDomain;
AssemblyName myAssemblyName;
MethodBuilder myMethodBuilder=null;
ILGenerator myILGenerator;
// Get the current application domain for the current thread.
currentDomain = AppDomain.CurrentDomain;
myAssemblyName = new AssemblyName();
myAssemblyName.Name = "TempAssembly";
// Define a dynamic assembly in the 'currentDomain'.
myAssemblyBuilder =
currentDomain.DefineDynamicAssembly
(myAssemblyName, AssemblyBuilderAccess.RunAndSave);
// Define a dynamic module in "TempAssembly" assembly.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule");
// Define a global method in the 'TempModule' module.
myMethodBuilder = myModuleBuilder.DefineGlobalMethod
("MyMethod1",MethodAttributes.Static|MethodAttributes.Public,
null,null);
myILGenerator = myMethodBuilder.GetILGenerator();
myILGenerator.EmitWriteLine("Hello World from global method.");
myILGenerator.Emit(OpCodes.Ret);
// Fix up the 'TempModule' module .
myModuleBuilder.CreateGlobalFunctions();
Dim currentDomain As AppDomain
Dim myAssemblyName As AssemblyName
Dim myMethodBuilder As MethodBuilder = Nothing
Dim myILGenerator As ILGenerator
' Get the current application domain for the current thread.
currentDomain = AppDomain.CurrentDomain
myAssemblyName = New AssemblyName()
myAssemblyName.Name = "TempAssembly"
' Define a dynamic assembly in the 'currentDomain'.
myAssemblyBuilder = currentDomain.DefineDynamicAssembly(myAssemblyName, _
AssemblyBuilderAccess.RunAndSave)
' Define a dynamic module in "TempAssembly" assembly.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule")
' Define a global method in the 'TempModule' module.
myMethodBuilder = myModuleBuilder.DefineGlobalMethod("MyMethod1", MethodAttributes.Static _
Or MethodAttributes.Public, Nothing, Nothing)
myILGenerator = myMethodBuilder.GetILGenerator()
myILGenerator.EmitWriteLine("Hello World from global method.")
myILGenerator.Emit(OpCodes.Ret)
' Fix up the 'TempModule' module .
myModuleBuilder.CreateGlobalFunctions()
Açıklamalar
Bu yöntemin tanımladığı genel yöntem, çağırana CreateGlobalFunctionskadar kullanılamaz.
Şunlara uygulanır
DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[])
Belirtilen ad, öznitelikler, çağırma kuralı, dönüş türü ve parametre türleri ile genel bir yöntem tanımlar.
public:
System::Reflection::Emit::MethodBuilder ^ DefineGlobalMethod(System::String ^ name, System::Reflection::MethodAttributes attributes, System::Reflection::CallingConventions callingConvention, Type ^ returnType, cli::array <Type ^> ^ parameterTypes);
public System.Reflection.Emit.MethodBuilder DefineGlobalMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, Type returnType, Type[] parameterTypes);
member this.DefineGlobalMethod : string * System.Reflection.MethodAttributes * System.Reflection.CallingConventions * Type * Type[] -> System.Reflection.Emit.MethodBuilder
Public Function DefineGlobalMethod (name As String, attributes As MethodAttributes, callingConvention As CallingConventions, returnType As Type, parameterTypes As Type()) As MethodBuilder
Parametreler
- name
- String
yönteminin adı.
name katıştırılmış null içeremez.
- attributes
- MethodAttributes
yönteminin öznitelikleri.
attributes içermelidir Static.
- callingConvention
- CallingConventions
yöntemi için çağırma kuralı.
- returnType
- Type
yönteminin dönüş türü.
- parameterTypes
- Type[]
Yöntemin parametrelerinin türleri.
Döndürülenler
Tanımlanan genel yöntem.
Özel durumlar
Yöntemi statik değil. Yani, attributes içermez Static.
-veya-
Dizideki Type bir öğe şeklindedir null.
name, null'e eşittir.
CreateGlobalFunctions() daha önce çağrıldı.
Örnekler
Aşağıdaki kod örneği, geçerli ModuleBuilderöğesine bağlı türünden bağımsız bir yöntem oluşturmak için öğesinin kullanımını DefineGlobalMethod gösterir. Genel yöntemi derledikten sonra tamamlamak CreateGlobalFunctions için çağrılmalıdır.
AppDomain currentDomain;
AssemblyName myAssemblyName;
MethodBuilder myMethodBuilder=null;
ILGenerator myILGenerator;
// Get the current application domain for the current thread.
currentDomain = AppDomain.CurrentDomain;
myAssemblyName = new AssemblyName();
myAssemblyName.Name = "TempAssembly";
// Define a dynamic assembly in the 'currentDomain'.
myAssemblyBuilder =
currentDomain.DefineDynamicAssembly
(myAssemblyName, AssemblyBuilderAccess.RunAndSave);
// Define a dynamic module in "TempAssembly" assembly.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule");
// Define a global method in the 'TempModule' module.
myMethodBuilder = myModuleBuilder.DefineGlobalMethod
("MyMethod1",MethodAttributes.Static|MethodAttributes.Public,
null,null);
myILGenerator = myMethodBuilder.GetILGenerator();
myILGenerator.EmitWriteLine("Hello World from global method.");
myILGenerator.Emit(OpCodes.Ret);
// Fix up the 'TempModule' module .
myModuleBuilder.CreateGlobalFunctions();
Dim currentDomain As AppDomain
Dim myAssemblyName As AssemblyName
Dim myMethodBuilder As MethodBuilder = Nothing
Dim myILGenerator As ILGenerator
' Get the current application domain for the current thread.
currentDomain = AppDomain.CurrentDomain
myAssemblyName = New AssemblyName()
myAssemblyName.Name = "TempAssembly"
' Define a dynamic assembly in the 'currentDomain'.
myAssemblyBuilder = currentDomain.DefineDynamicAssembly(myAssemblyName, _
AssemblyBuilderAccess.RunAndSave)
' Define a dynamic module in "TempAssembly" assembly.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule")
' Define a global method in the 'TempModule' module.
myMethodBuilder = myModuleBuilder.DefineGlobalMethod("MyMethod1", MethodAttributes.Static _
Or MethodAttributes.Public, Nothing, Nothing)
myILGenerator = myMethodBuilder.GetILGenerator()
myILGenerator.EmitWriteLine("Hello World from global method.")
myILGenerator.Emit(OpCodes.Ret)
' Fix up the 'TempModule' module .
myModuleBuilder.CreateGlobalFunctions()
Açıklamalar
çağırana CreateGlobalFunctionskadar bu yöntemin tanımladığı genel yöntemi kullanamazsınız.
Şunlara uygulanır
DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type[], Type[], Type[][], Type[][])
Belirtilen ada, özniteliklere, çağırma kuralına, dönüş türüne, dönüş türüne yönelik özel değiştiricilere, parametre türlerine ve parametre türleri için özel değiştiricilere sahip genel bir yöntem tanımlar.
public:
System::Reflection::Emit::MethodBuilder ^ DefineGlobalMethod(System::String ^ name, System::Reflection::MethodAttributes attributes, System::Reflection::CallingConventions callingConvention, Type ^ returnType, cli::array <Type ^> ^ requiredReturnTypeCustomModifiers, cli::array <Type ^> ^ optionalReturnTypeCustomModifiers, cli::array <Type ^> ^ parameterTypes, cli::array <cli::array <Type ^> ^> ^ requiredParameterTypeCustomModifiers, cli::array <cli::array <Type ^> ^> ^ optionalParameterTypeCustomModifiers);
public System.Reflection.Emit.MethodBuilder DefineGlobalMethod(string name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers);
member this.DefineGlobalMethod : string * System.Reflection.MethodAttributes * System.Reflection.CallingConventions * Type * Type[] * Type[] * Type[] * Type[][] * Type[][] -> System.Reflection.Emit.MethodBuilder
Public Function DefineGlobalMethod (name As String, attributes As MethodAttributes, callingConvention As CallingConventions, returnType As Type, requiredReturnTypeCustomModifiers As Type(), optionalReturnTypeCustomModifiers As Type(), parameterTypes As Type(), requiredParameterTypeCustomModifiers As Type()(), optionalParameterTypeCustomModifiers As Type()()) As MethodBuilder
Parametreler
- name
- String
yönteminin adı.
name eklenmiş null karakterler içeremez.
- attributes
- MethodAttributes
yönteminin öznitelikleri.
attributes içermelidir Static.
- callingConvention
- CallingConventions
yöntemi için çağırma kuralı.
- returnType
- Type
yönteminin dönüş türü.
- requiredReturnTypeCustomModifiers
- Type[]
veya IsBoxedgibi IsConst dönüş türü için gerekli özel değiştiricileri temsil eden bir tür dizisi. Dönüş türünde gerekli özel değiştirici yoksa belirtin null.
- optionalReturnTypeCustomModifiers
- Type[]
veya IsBoxedgibi IsConst dönüş türü için isteğe bağlı özel değiştiricileri temsil eden bir tür dizisi. Dönüş türünde isteğe bağlı özel değiştirici yoksa belirtin null.
- parameterTypes
- Type[]
Yöntemin parametrelerinin türleri.
- requiredParameterTypeCustomModifiers
- Type[][]
Tür dizileri dizisi. Her tür dizisi, genel yöntemin ilgili parametresi için gerekli özel değiştiricileri temsil eder. Belirli bir bağımsız değişkenin gerekli özel değiştiricisi yoksa, bir tür dizisi yerine belirtin null . Genel yöntemin bağımsız değişkeni yoksa veya bağımsız değişkenlerden hiçbirinde özel değiştirici gerekli değilse, dizi dizisi yerine belirtin null .
- optionalParameterTypeCustomModifiers
- Type[][]
Tür dizileri dizisi. Her tür dizisi, ilgili parametre için isteğe bağlı özel değiştiricileri temsil eder. Belirli bir bağımsız değişkenin isteğe bağlı özel değiştiricisi yoksa, tür dizisi yerine belirtin null . Genel yöntemin bağımsız değişkeni yoksa veya bağımsız değişkenlerden hiçbiri isteğe bağlı özel değiştiricilere sahip değilse, dizi dizisi yerine belirtin null .
Döndürülenler
Tanımlanan genel yöntem.
Özel durumlar
Yöntemi statik değil. Yani, attributes içermez Static.
-veya-
Dizideki Type bir öğe şeklindedir null.
name, null'e eşittir.
yöntemi CreateGlobalFunctions() daha önce çağrıldı.
Açıklamalar
Bu aşırı yükleme, yönetilen derleyici tasarımcıları için sağlanır.
çağırana CreateGlobalFunctionskadar bu yöntemin tanımladığı genel yöntemi kullanamazsınız.