Most basic event action manager.
2 using System.Collections.Generic;
5 using System.Threading.Tasks;
7 using System.Reflection;
10 namespace SharpLib.Utils
12 public class Reflection
17 /// <typeparam name="T"></typeparam>
18 /// <returns></returns>
19 public static IEnumerable<Type> GetConcreteClassesDerivedFrom<T>() where T : class
21 List<Type> objects = new List<Type>();
23 Assembly.GetAssembly(typeof(T)).GetTypes()
24 .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T))))
35 /// <typeparam name="T"></typeparam>
36 /// <returns></returns>
37 public static IDictionary<string, Type> GetConcreteClassesDerivedFromByName<T>() where T : class
39 Dictionary<string, Type> objects = new Dictionary<string, Type>();
41 Assembly.GetAssembly(typeof(T)).GetTypes()
42 .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T))))
44 objects.Add(type.Name,type);
53 /// <typeparam name="T"></typeparam>
54 /// <returns></returns>
55 public static IEnumerable<T> GetConcreteClassesInstanceDerivedFrom<T>() where T : class
57 List<T> objects = new List<T>();
59 Assembly.GetAssembly(typeof(T)).GetTypes()
60 .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T))))
62 objects.Add((T)Activator.CreateInstance(type));
66 && objects[0] is IComparable)
77 /// <typeparam name="T"></typeparam>
78 /// <returns></returns>
79 public static IDictionary<string, T> GetConcreteClassesInstanceDerivedFromByName<T>() where T : class
81 Dictionary<string, T> objects = new Dictionary<string, T>();
83 Assembly.GetAssembly(typeof(T)).GetTypes()
84 .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T))))
86 objects.Add(type.Name,(T)Activator.CreateInstance(type));
98 /// <typeparam name="T"></typeparam>
99 /// <param name="aType"></param>
100 /// <returns></returns>
101 public static T GetAttribute<T>(Type aType) where T : class
103 object[] attrs = aType.GetCustomAttributes(true);
104 foreach (object attr in attrs)
106 T attribute = attr as T;
107 if (attribute != null)