public bool removeEventListener(string eventType, EventListener listener, EventListenerOptions options) { lock (this) { if (_eventEntries.TryGetValue(eventType, out var eventEntry)) { var r = eventEntry.RemoveAll(x => x.options.capture == options.capture) > 0; if (eventEntry.Count == 0) { _eventEntries.Remove(eventType); } return(r); } } return(false); }
public bool addEventListener(string eventType, EventListener listener, EventListenerOptions options) { lock (this) { if (_eventEntries.TryGetValue(eventType, out var eventEntry)) { if (eventEntry.Any(x => x.options.capture == options.capture)) { return(false); } _eventEntries[eventType].Add(new EventEntry(listener, options)); return(true); } _eventEntries[eventType] = new List <EventEntry> { new EventEntry(listener, options) }; return(true); } }
public EventEntry(EventListener l, EventListenerOptions o) { listener = l; options = o; }