/// <summary> /// Gets or sets the delegate for the specified key. /// </summary> public Delegate?this[object key] { get { ListEntry?e = null; if (_parent == null || _parent.CanRaiseEventsInternal) { e = Find(key); } return(e?._handler); } set { ListEntry?e = Find(key); if (e != null) { e._handler = value; } else { _head = new ListEntry(key, value, _head); } } }
public void RemoveHandler(object key, Delegate?value) { ListEntry?e = Find(key); if (e != null) { e._handler = Delegate.Remove(e._handler, value); } }
public void AddHandlers(EventHandlerList listToAddFrom) { ArgumentNullException.ThrowIfNull(listToAddFrom); ListEntry?currentListEntry = listToAddFrom._head; while (currentListEntry != null) { AddHandler(currentListEntry._key, currentListEntry._handler); currentListEntry = currentListEntry._next; } }
public void AddHandler(object key, Delegate?value) { ListEntry?e = Find(key); if (e != null) { e._handler = Delegate.Combine(e._handler, value); } else { _head = new ListEntry(key, value, _head); } }
private ListEntry?Find(object key) { ListEntry?found = _head; while (found != null) { if (found._key == key) { break; } found = found._next; } return(found); }
public void AddHandlers(EventHandlerList listToAddFrom) { if (listToAddFrom == null) { throw new ArgumentNullException(nameof(listToAddFrom)); } ListEntry?currentListEntry = listToAddFrom._head; while (currentListEntry != null) { AddHandler(currentListEntry._key, currentListEntry._handler); currentListEntry = currentListEntry._next; } }
public void Dispose() => _head = null;
public ListEntry(object key, Delegate?handler, ListEntry?next) { _next = next; _key = key; _handler = handler; }