public static void FireTypedEvent <TEventParam>(TypedDelegate <TEventParam> pEvent, TEventParam pParam) { TypedDelegate <TEventParam> eh = pEvent; if (eh != null) { eh(pParam); } }
/// <summary> /// Removes a listener for a specified event type. /// </summary> public virtual void RemoveListener <T>(TypedDelegate <T> listener) where T : class { var type = typeof(T); if (delegates.ContainsKey(type)) { delegates[type].Remove(listener); return; } }
/// <summary> /// Adds a listener for a specified event type. /// </summary> public virtual void AddListener <T>(TypedDelegate <T> listener) where T : class { var type = typeof(T); if (!delegates.ContainsKey(type)) { delegates.Add(type, new List <Delegate>()); } var list = delegates[type]; if (!list.Contains(listener)) { list.Add(listener); } }