EventAttributes 열거형
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이벤트의 특성을 지정합니다.
이 열거형은 멤버 값의 비트 조합을 지원합니다.
public enum class EventAttributes
[System.Flags]
public enum EventAttributes
[System.Flags]
[System.Serializable]
public enum EventAttributes
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum EventAttributes
[<System.Flags>]
type EventAttributes =
[<System.Flags>]
[<System.Serializable>]
type EventAttributes =
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type EventAttributes =
Public Enum EventAttributes
- 상속
- 특성
필드
| Name | 값 | Description |
|---|---|---|
| None | 0 | 이벤트에 특성이 없음을 지정합니다. |
| SpecialName | 512 | 이벤트가 이름으로 설명된 방식으로 특수하다는 것을 지정합니다. |
| ReservedMask | 1024 | 공용 언어 런타임에만 사용할 예약 플래그를 지정합니다. |
| RTSpecialName | 1024 | 공용 언어 런타임에서 이름 인코딩을 검사해야 되도록 지정합니다. |
예제
다음 예제에서는 리플렉션 내보내기를 사용하여 두 개의 이벤트가 있는 형식을 만듭니다. None을 사용하여 이벤트에 특성이 없음을 지정합니다.
using System;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;
public class MyApplication
{
public delegate void MyEvent(Object temp);
public static void Main()
{
TypeBuilder helloWorldClass = CreateCallee(Thread.GetDomain());
EventInfo[] info =
helloWorldClass.GetEvents(BindingFlags.Public | BindingFlags.Instance);
Console.WriteLine("'HelloWorld' type has following events :");
for(int i=0; i < info.Length; i++)
Console.WriteLine(info[i].Name);
}
// Create the callee transient dynamic assembly.
private static TypeBuilder CreateCallee(AppDomain myDomain)
{
AssemblyName assemblyName = new AssemblyName();
assemblyName.Name = "EmittedAssembly";
// Create the callee dynamic assembly.
AssemblyBuilder myAssembly =
myDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
// Create a dynamic module named "CalleeModule" in the callee.
ModuleBuilder myModule = myAssembly.DefineDynamicModule("EmittedModule");
// Define a public class named "HelloWorld" in the assembly.
TypeBuilder helloWorldClass =
myModule.DefineType("HelloWorld", TypeAttributes.Public);
MethodBuilder myMethod1 = helloWorldClass.DefineMethod("OnClick",
MethodAttributes.Public, typeof(void), new Type[]{typeof(Object)});
ILGenerator methodIL1 = myMethod1.GetILGenerator();
methodIL1.Emit(OpCodes.Ret);
MethodBuilder myMethod2 = helloWorldClass.DefineMethod("OnMouseUp",
MethodAttributes.Public, typeof(void), new Type[]{typeof(Object)});
ILGenerator methodIL2 = myMethod2.GetILGenerator();
methodIL2.Emit(OpCodes.Ret);
// Create the events.
EventBuilder myEvent1 = helloWorldClass.DefineEvent("Click", EventAttributes.None,
typeof(MyEvent));
myEvent1.SetRaiseMethod(myMethod1);
EventBuilder myEvent2 = helloWorldClass.DefineEvent("MouseUp", EventAttributes.None,
typeof(MyEvent));
myEvent2.SetRaiseMethod(myMethod2);
helloWorldClass.CreateType();
return(helloWorldClass);
}
}
Imports System.Threading
Imports System.Reflection
Imports System.Reflection.Emit
Public Class MyApplication
Delegate Sub MyEvent(temp As Object)
Public Shared Sub Main()
Dim helloWorldClass As TypeBuilder = CreateCallee(Thread.GetDomain())
Dim info As EventInfo() = helloWorldClass.GetEvents(BindingFlags.Public Or _
BindingFlags.Instance)
Console.WriteLine("'HelloWorld' type has following events :")
Dim i As Integer
For i = 0 To info.Length - 1
Console.WriteLine(info(i).Name)
Next i
End Sub
' Create the callee transient dynamic assembly.
Private Shared Function CreateCallee(myDomain As AppDomain) As TypeBuilder
Dim myAssemblyName As New AssemblyName()
myAssemblyName.Name = "EmittedAssembly"
' Create the callee dynamic assembly.
Dim myAssembly As AssemblyBuilder = myDomain.DefineDynamicAssembly _
(myAssemblyName, AssemblyBuilderAccess.Run)
' Create a dynamic module named "CalleeModule" in the callee
Dim myModule As ModuleBuilder = myAssembly.DefineDynamicModule("EmittedModule")
' Define a public class named "HelloWorld" in the assembly.
Dim helloWorldClass As TypeBuilder = myModule.DefineType _
("HelloWorld", TypeAttributes.Public)
Dim myMethod1 As MethodBuilder = helloWorldClass.DefineMethod _
("OnClick", MethodAttributes.Public, Nothing, New Type() {GetType(Object)})
Dim methodIL1 As ILGenerator = myMethod1.GetILGenerator()
methodIL1.Emit(OpCodes.Ret)
Dim myMethod2 As MethodBuilder = helloWorldClass.DefineMethod _
("OnMouseUp", MethodAttributes.Public, Nothing, New Type() {GetType(Object)})
Dim methodIL2 As ILGenerator = myMethod2.GetILGenerator()
methodIL2.Emit(OpCodes.Ret)
' Create the events.
Dim myEvent1 As EventBuilder = helloWorldClass.DefineEvent _
("Click", EventAttributes.None, GetType(MyEvent))
myEvent1.SetRaiseMethod(myMethod1)
Dim myEvent2 As EventBuilder = helloWorldClass.DefineEvent _
("MouseUp", EventAttributes.None, GetType(MyEvent))
myEvent2.SetRaiseMethod(myMethod2)
helloWorldClass.CreateType()
Return helloWorldClass
End Function 'CreateCallee
End Class
설명
EventAttributes 값은 비트 OR 연산을 사용하여 적절한 조합을 가져올 수 있습니다.
이러한 열거형은 corhdr.h 파일에 정의되며 비트와 열거자의 조합입니다.