public static void AddHandler(IDoubleActionProvider provider, DoubleActionEventHandler handler) { DoubleActionDispatcher dispatcher; if (map.ContainsKey(provider)) { dispatcher = map[provider]; } else { dispatcher = new DoubleActionDispatcher(provider); map.Add(provider, dispatcher); } dispatcher.DoubleActionEvent += handler; }
public static void RemoveHandler(IDoubleActionProvider provider, DoubleActionEventHandler handler) { if (!map.ContainsKey(provider)) { return; } DoubleActionDispatcher dispatcher = map[provider]; dispatcher.DoubleActionEvent -= handler; if (dispatcher.DoubleActionEvent.GetInvocationList().Length == 0) { dispatcher.Release(); map.Remove(provider); } }
/// <summary> /// Initializes a new instance of the <see cref="ActionDispatcher"/> class. /// </summary> /// <param name="provider">The provider.</param> protected DoubleActionDispatcher(IDoubleActionProvider provider) : base(provider) { provider.DoubleAction = ObjectiveCRuntime.Selector("doDoubleAction:"); }