Reflection functions now working on all loaded assemblies.
5 using System.Collections.Generic;
6 using System.ComponentModel;
8 using System.Reflection;
9 using System.Runtime.Serialization;
12 namespace SharpLib.Ear
14 [TypeConverter(typeof(TypeConverterJson<ManagerEventAction>))]
16 public class ManagerEventAction
18 public static ManagerEventAction Current = null;
19 public IDictionary<string, Type> ActionTypes;
20 public IDictionary<string, Event> Events;
22 public Dictionary<string, List<Action>> ActionsByEvents = new Dictionary<string, List<Action>>();
25 public ManagerEventAction()
35 //Create our list of supported actions
36 ActionTypes = Utils.Reflection.GetConcreteClassesDerivedFromByName<Action>();
37 //Create our list or support events
38 Events = Utils.Reflection.GetConcreteClassesInstanceDerivedFromByName<Event>();
40 if (ActionsByEvents == null)
43 ActionsByEvents = new Dictionary<string, List<Action>>();
46 //Hook in loaded actions with corresponding events
47 foreach (string key in Events.Keys)
49 Event e = Events[key];
50 if (ActionsByEvents.ContainsKey(key))
52 //We have actions for that event, hook them in then
53 e.Actions = ActionsByEvents[key];
57 //We do not have actions for that event yet, create empty action list
58 e.Actions = new List<Action>();
59 ActionsByEvents[key] = e.Actions;
64 public Event GetEvent<T>() where T : class
66 return Events[typeof(T).Name];