다음을 통해 공유


EventAttributes 열거형

이벤트의 특성을 지정합니다.

이 열거형에는 멤버 값를 비트로 조합할 수 있는 FlagsAttribute 특성이 있습니다.

네임스페이스: System.Reflection
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
<SerializableAttribute> _
<FlagsAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration EventAttributes
‘사용 방법
Dim instance As EventAttributes
[SerializableAttribute] 
[FlagsAttribute] 
[ComVisibleAttribute(true)] 
public enum EventAttributes
[SerializableAttribute] 
[FlagsAttribute] 
[ComVisibleAttribute(true)] 
public enum class EventAttributes
/** @attribute SerializableAttribute() */ 
/** @attribute FlagsAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum EventAttributes
SerializableAttribute 
FlagsAttribute 
ComVisibleAttribute(true) 
public enum EventAttributes

멤버

  멤버 이름 설명
Supported by the .NET Compact Framework None 이벤트에 특성이 포함되지 않도록 지정합니다. 
Supported by the .NET Compact Framework ReservedMask 공용 언어 런타임 전용의 예약 플래그를 지정합니다. 
Supported by the .NET Compact Framework RTSpecialName 공용 언어 런타임에서 이름 인코딩을 확인하도록 지정합니다. 
Supported by the .NET Compact Framework SpecialName 이름을 사용하여 설명하는 방법으로 이벤트를 지정합니다. 

설명

EventAttributes 값은 적절한 결합을 가져오도록 비트 OR 연산을 사용하여 결합할 수 있습니다.

이러한 열거형은 corhdr.h 파일에 정의되어 있으며 비트와 열거자의 결합입니다.

예제

Imports System
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 'Main

   ' 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 'MyApplication
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);
   }
}
using namespace System;
using namespace System::Threading;
using namespace System::Reflection;
using namespace System::Reflection::Emit;

ref class MyApplication
{
private:
   delegate void MyEvent( Object^ temp );

public:

   // Create the callee transient dynamic assembly.
   static TypeBuilder^ CreateCallee( AppDomain^ myDomain )
   {
      AssemblyName^ assemblyName = gcnew AssemblyName;
      assemblyName->Name = "EmittedAssembly";
      
      // Create the callee dynamic assembly.
      AssemblyBuilder^ myAssembly = myDomain->DefineDynamicAssembly( assemblyName, AssemblyBuilderAccess::Run );
      
      // Create a dynamic module
      ModuleBuilder^ myModule = myAssembly->DefineDynamicModule( "EmittedModule" );
      
      // Define a public class named "HelloWorld" in the assembly.
      TypeBuilder^ helloWorldClass = myModule->DefineType( "HelloWorld", TypeAttributes::Public );
      array<Type^>^typeArray = gcnew array<Type^>(1);
      typeArray[ 0 ] = Object::typeid;
      MethodBuilder^ myMethod1 = helloWorldClass->DefineMethod( "OnClick", MethodAttributes::Public, void::typeid, typeArray );
      ILGenerator^ methodIL1 = myMethod1->GetILGenerator();
      methodIL1->Emit( OpCodes::Ret );
      MethodBuilder^ myMethod2 = helloWorldClass->DefineMethod( "OnMouseUp", MethodAttributes::Public, void::typeid, typeArray );
      ILGenerator^ methodIL2 = myMethod2->GetILGenerator();
      methodIL2->Emit( OpCodes::Ret );
      
      // Create the events.
      EventBuilder^ myEvent1 = helloWorldClass->DefineEvent( "Click", EventAttributes::None, MyEvent::typeid );
      myEvent1->SetRaiseMethod( myMethod1 );
      EventBuilder^ myEvent2 = helloWorldClass->DefineEvent( "MouseUp", EventAttributes::None, MyEvent::typeid );
      myEvent2->SetRaiseMethod( myMethod2 );
      helloWorldClass->CreateType();
      return (helloWorldClass);
   }
};

int main()
{
   TypeBuilder^ helloWorldClass = MyApplication::CreateCallee( Thread::GetDomain() );
   array<EventInfo^>^info = helloWorldClass->GetEvents( static_cast<BindingFlags>(BindingFlags::Public | BindingFlags::Instance) );
   Console::WriteLine( "'HelloWorld' type has following events :" );
   for ( int i = 0; i < info->Length; i++ )
      Console::WriteLine( info[ i ]->Name );
   return 0;
}
import System.*;
import System.Threading.*;
import System.Reflection.*;
import System.Reflection.Emit.*;

public class MyApplication
{
    /** @delegate 
     */
    public delegate void MyEvent(Object temp);

    public static void main(String[] args)
    {
        TypeBuilder helloWorldClass =
            CreateCallee(System.Threading.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].get_Name());
        }
    } //main

    // Create the callee transient dynamic assembly.
    private static TypeBuilder CreateCallee(AppDomain myDomain)
    {
        AssemblyName assemblyName = new AssemblyName();
        assemblyName.set_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, void.class.ToType(),
            new Type[] { Object.class.ToType() });
        ILGenerator methodIL1 = myMethod1.GetILGenerator();
        methodIL1.Emit(OpCodes.Ret);
        MethodBuilder myMethod2 = helloWorldClass.DefineMethod("OnMouseUp",
            MethodAttributes.Public, void.class.ToType(),
            new Type[] { Object.class.ToType() });
        ILGenerator methodIL2 = myMethod2.GetILGenerator();
        methodIL2.Emit(OpCodes.Ret);
        // Create the events.
        EventBuilder myEvent1 = helloWorldClass.DefineEvent("Click",
            EventAttributes.None, MyEvent.class.ToType());
        myEvent1.SetRaiseMethod(myMethod1);
        EventBuilder myEvent2 = helloWorldClass.DefineEvent("MouseUp",
            EventAttributes.None, MyEvent.class.ToType());
        myEvent2.SetRaiseMethod(myMethod2);

        helloWorldClass.CreateType();
        return helloWorldClass;
    } //CreateCallee
}//MyApplication

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

System.Reflection 네임스페이스