Show Events : Event « Reflection « C# / C Sharp






Show Events

   
using System;
using System.Reflection;

class MainClass {

    public static void ShowEvents(Type t) {
        EventInfo[] events = t.GetEvents();
        Console.WriteLine("Implemented Events");
        foreach (EventInfo e in events) {
            Console.WriteLine("Event name: {0}", e.Name);
            Console.WriteLine("Multicast: {0}", e.IsMulticast ? "Yes" : "No");
            Console.WriteLine("Member Type {0}", e.MemberType.ToString());
        }
    }

    public static void ShowTypes(string name, Assembly assembly) {
        Type[] typeArray = assembly.GetTypes();

        Console.WriteLine("Assembly Name: {0}", name);
        foreach (Type type in typeArray) {
            if (type.IsClass) {

                ShowEvents(type);
            } 
        }
    }
    public static void Main(string[] args) {
        for (int i = 0; i < args.Length; ++i) {
            // Get the assemble object (from System.Reflection)
            Assembly assembly = Assembly.LoadFrom(args[0]);

            ShowTypes(args[0], assembly);
        }
    }
}

   
    
  








Related examples in the same category

1.EventInfo Class discovers the attributes of an event and provides access to event metadata.
2.Use reflection to get the Elapsed event
3.Get event handler type
4.EventInfo.EventHandlerType
5.Returns the EventInfo object representing the specified public event.
6.Returns the EventInfo object representing the specified event, using the specified binding constraints.
7.Search for events that are declared or inherited by the current Type, using the specified binding constraints.
8.Returns all the public events that are declared or inherited by the current Type.