public static void RemoveListener <T>(CTEventCallBack <T> callback) where T : CTEvent { if (eventDictionary.ContainsKey(typeof(T))) { foreach (KeyValuePair <System.Type, List <System.Delegate> > callBackDefinition in eventDictionary) { if (callBackDefinition.Key == typeof(T)) { callBackDefinition.Value.Remove(callback); } } } }
public static void AddListener <T>(CTEventCallBack <T> callback) where T : CTEvent { if (eventDictionary.ContainsKey(typeof(T))) { foreach (KeyValuePair <System.Type, List <System.Delegate> > callBackDefinition in eventDictionary) { if (callBackDefinition.Key == typeof(T)) { callBackDefinition.Value.Add(callback); } } } else { List <System.Delegate> callbacks = new List <System.Delegate>(); callbacks.Add(callback); eventDictionary.Add(typeof(T), callbacks); } }