public void AddCallbackListener(string eventType, EVENT_DELEGATE listener) { Delegate d = null; if (mDelegates.TryGetValue(eventType, out d)) { mDelegates[eventType] = Delegate.Combine(d, listener); } else { mDelegates[eventType] = listener; } }
public bool SendCallbackEvent(string eventType) { Delegate d = null; if (mDelegates.TryGetValue(eventType, out d)) { EVENT_DELEGATE callback = d as EVENT_DELEGATE; if (callback != null) { return(callback()); } } return(false); }
public void RemoveCallbackListener(string eventType, EVENT_DELEGATE listener) { Delegate d = null; if (mDelegates.TryGetValue(eventType, out d)) { Delegate currentDel = Delegate.Remove(d, listener); if (currentDel == null) { mDelegates.Remove(eventType); } else { mDelegates[eventType] = currentDel; } } }
public bool SendCallbackEvent <T>(string eventType, T arg) { if (arg == null) { throw new ArgumentNullException("arg"); } Delegate d = null; if (mDelegates.TryGetValue(eventType, out d)) { EVENT_DELEGATE <T> callback = d as EVENT_DELEGATE <T>; if (callback != null) { return(callback(arg)); } } return(false); }