Csharp/C Sharp by API/System.Reflection/EventInfo

Материал из .Net Framework эксперт
Версия от 12:11, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

EventInfo.IsMulticast

  
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);
        }
    }
}


EventInfo.MemberType

  
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);
        }
    }
}