ModuleBuilder.DefineGlobalMethod 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
전역 메서드를 정의합니다.
오버로드
| Name | Description |
|---|---|
| DefineGlobalMethod(String, MethodAttributes, Type, Type[]) |
지정된 이름, 특성, 반환 형식 및 매개 변수 형식을 사용하여 전역 메서드를 정의합니다. |
| DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[]) |
지정된 이름, 특성, 호출 규칙, 반환 형식 및 매개 변수 형식을 사용하여 전역 메서드를 정의합니다. |
| DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type[], Type[], Type[][], Type[][]) |
지정된 이름, 특성, 호출 규칙, 반환 형식, 반환 형식에 대한 사용자 지정 한정자, 매개 변수 형식 및 매개 변수 형식에 대한 사용자 지정 한정자를 사용하여 전역 메서드를 정의합니다. |
DefineGlobalMethod(String, MethodAttributes, Type, Type[])
지정된 이름, 특성, 반환 형식 및 매개 변수 형식을 사용하여 전역 메서드를 정의합니다.
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
매개 변수
- name
- String
메서드의 이름입니다.
name 은 포함된 null을 포함할 수 없습니다.
- attributes
- MethodAttributes
메서드의 특성입니다.
attributes 를 포함 Static해야 합니다.
- returnType
- Type
메서드의 반환 형식입니다.
- parameterTypes
- Type[]
메서드 매개 변수의 형식입니다.
반품
정의된 전역 메서드입니다.
예외
name은 null입니다.
CreateGlobalFunctions() 가 이전에 호출되었습니다.
예제
다음 예제에서는 현재ModuleBuilder에 연결된 형식 독립적 메서드를 만드는 방법을 보여 DefineGlobalMethod 줍니다. 전역 메서드 CreateGlobalFunctions 를 빌드한 후 완료하려면 호출해야 합니다.
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()
설명
이 메서드가 정의하는 전역 메서드는 호출 CreateGlobalFunctions할 때까지 사용할 수 없습니다.
적용 대상
DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[])
지정된 이름, 특성, 호출 규칙, 반환 형식 및 매개 변수 형식을 사용하여 전역 메서드를 정의합니다.
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
매개 변수
- name
- String
메서드의 이름입니다.
name 은 포함된 null을 포함할 수 없습니다.
- attributes
- MethodAttributes
메서드의 특성입니다.
attributes 를 포함 Static해야 합니다.
- callingConvention
- CallingConventions
메서드에 대한 호출 규칙입니다.
- returnType
- Type
메서드의 반환 형식입니다.
- parameterTypes
- Type[]
메서드 매개 변수의 형식입니다.
반품
정의된 전역 메서드입니다.
예외
name은 null입니다.
CreateGlobalFunctions() 가 이전에 호출되었습니다.
예제
다음 코드 샘플에서는 현재ModuleBuilder에 연결된 형식 독립적 메서드를 만드는 방법을 DefineGlobalMethod 보여 줍니다. 전역 메서드 CreateGlobalFunctions 를 빌드한 후 완료하려면 호출해야 합니다.
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()
설명
호출 CreateGlobalFunctions할 때까지 이 메서드가 정의하는 전역 메서드를 사용할 수 없습니다.
적용 대상
DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type[], Type[], Type[][], Type[][])
지정된 이름, 특성, 호출 규칙, 반환 형식, 반환 형식에 대한 사용자 지정 한정자, 매개 변수 형식 및 매개 변수 형식에 대한 사용자 지정 한정자를 사용하여 전역 메서드를 정의합니다.
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
매개 변수
- name
- String
메서드의 이름입니다.
name 에는 포함된 null 문자가 포함될 수 없습니다.
- attributes
- MethodAttributes
메서드의 특성입니다.
attributes 를 포함 Static해야 합니다.
- callingConvention
- CallingConventions
메서드에 대한 호출 규칙입니다.
- returnType
- Type
메서드의 반환 형식입니다.
- requiredReturnTypeCustomModifiers
- Type[]
반환 형식에 필요한 사용자 지정 한정자를 나타내는 형식의 배열입니다(예: IsConst 또는 IsBoxed.). 반환 형식에 필수 사용자 지정 한정자가 null없으면 .
- optionalReturnTypeCustomModifiers
- Type[]
반환 형식에 대한 선택적 사용자 지정 한정자를 나타내는 형식 배열(예: IsConst 또는 IsBoxed. 반환 형식에 선택적 사용자 지정 한정자가 null없는 경우 .
- parameterTypes
- Type[]
메서드 매개 변수의 형식입니다.
- requiredParameterTypeCustomModifiers
- Type[][]
형식 배열의 배열입니다. 각 형식 배열은 전역 메서드의 해당 매개 변수에 필요한 사용자 지정 한정자를 나타냅니다. 특정 인수에 필수 사용자 지정 한정자가 없는 경우 형식 배열 대신 지정 null 합니다. 전역 메서드에 인수가 없거나 필요한 사용자 지정 한정자가 없는 경우 배열 배열 대신 지정 null 합니다.
- optionalParameterTypeCustomModifiers
- Type[][]
형식 배열의 배열입니다. 각 형식 배열은 해당 매개 변수에 대한 선택적 사용자 지정 한정자를 나타냅니다. 특정 인수에 선택적 사용자 지정 한정자가 없는 경우 형식 배열 대신 지정 null 합니다. 전역 메서드에 인수가 없거나 선택적 사용자 지정 한정자가 없는 경우 배열 배열 대신 지정 null 합니다.
반품
정의된 전역 메서드입니다.
예외
name은 null입니다.
메서드가 CreateGlobalFunctions() 이전에 호출되었습니다.
설명
이 오버로드는 관리되는 컴파일러의 디자이너에 대해 제공됩니다.
호출 CreateGlobalFunctions할 때까지 이 메서드가 정의하는 전역 메서드를 사용할 수 없습니다.