예제 #1
0
        /// <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);
                }
            }
        }
예제 #2
0
        public void RemoveHandler(object key, Delegate?value)
        {
            ListEntry?e = Find(key);

            if (e != null)
            {
                e._handler = Delegate.Remove(e._handler, value);
            }
        }
예제 #3
0
        public void AddHandlers(EventHandlerList listToAddFrom)
        {
            ArgumentNullException.ThrowIfNull(listToAddFrom);

            ListEntry?currentListEntry = listToAddFrom._head;

            while (currentListEntry != null)
            {
                AddHandler(currentListEntry._key, currentListEntry._handler);
                currentListEntry = currentListEntry._next;
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        private ListEntry?Find(object key)
        {
            ListEntry?found = _head;

            while (found != null)
            {
                if (found._key == key)
                {
                    break;
                }
                found = found._next;
            }
            return(found);
        }
예제 #6
0
        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;
            }
        }
예제 #7
0
 public void Dispose() => _head = null;
예제 #8
0
 public ListEntry(object key, Delegate?handler, ListEntry?next)
 {
     _next    = next;
     _key     = key;
     _handler = handler;
 }