/// <summary> /// Unsubscribes an action from an event. /// </summary> /// <param name="name">Name of event.</param> /// <param name="action">Action to remove.</param> public static void Unsubscribe(string name, Action action) { // Get list of actions. List <ECCBaseEventAction> actions; if (!m_EventsDict.TryGetValue(name, out actions)) { return; } // Search for action to remove. for (int i = 0; i < actions.Count; i++) { ECCEventAction eventAction = actions[i] as ECCEventAction; if (eventAction.EqualsAction(action)) { actions.RemoveAt(i); break; } } if (actions.Count == 0) { m_EventsDict.Remove(name); } }
/// <summary> /// Subscribes a three parameter action to an event. /// </summary> /// <param name="name">Name of event.</param> /// <param name="action">Action to add.</param> public static void Subscribe <T1, T2, T3>(string name, Action <T1, T2, T3> action) { ECCEventAction <T1, T2, T3> eventAction = new ECCEventAction <T1, T2, T3>(action); Subscribe(name, eventAction); }
/// <summary> /// Subscribes an action to an event. /// </summary> /// <param name="name">Name of event.</param> /// <param name="action">Action to add.</param> public static void Subscribe(string name, Action action) { ECCEventAction eventAction = new ECCEventAction(action); Subscribe(name, eventAction); }