Ejemplo n.º 1
0
        private WeakMulticastDelegate Remove(Delegate realDelegate)
        {
            WeakMulticastDelegate result;

            if (this.Equals(realDelegate))
            {
                result = this.prev;
            }
            else
            {
                WeakMulticastDelegate current = this.prev;
                WeakMulticastDelegate last    = this;
                while (current != null)
                {
                    if (current.Equals(realDelegate))
                    {
                        last.prev    = current.prev;
                        current.prev = null;
                        break;
                    }
                    last    = current;
                    current = current.prev;
                }
                result = this;
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Combines this weak multicast delegate with a normal delegate
        /// Makes sure the delegate target has not been added yet
        /// </summary>
        /// <param name="realDelegate">the real delegate</param>
        /// <returns>the new weak multicast delegate</returns>
        private WeakMulticastDelegate CombineUnique(Delegate realDelegate)
        {
            bool found = Equals(realDelegate);

            if (!found && prev != null)
            {
                WeakMulticastDelegate curNode = prev;
                while (!found && curNode != null)
                {
                    if (curNode.Equals(realDelegate))
                    {
                        found = true;
                    }
                    curNode = curNode.prev;
                }
            }
            return(found ? this : Combine(realDelegate));
        }
Ejemplo n.º 3
0
        private WeakMulticastDelegate CombineUnique(Delegate realDelegate)
        {
            bool flag = this.Equals(realDelegate);

            if (!flag && this.prev != null)
            {
                WeakMulticastDelegate weakMulticastDelegate = this.prev;
                while (!flag && weakMulticastDelegate != null)
                {
                    if (weakMulticastDelegate.Equals(realDelegate))
                    {
                        flag = true;
                    }
                    weakMulticastDelegate = weakMulticastDelegate.prev;
                }
            }
            if (!flag)
            {
                return(this.Combine(realDelegate));
            }
            return(this);
        }
Ejemplo n.º 4
0
        private WeakMulticastDelegate Remove(Delegate realDelegate)
        {
            if (this.Equals(realDelegate))
            {
                return(this.prev);
            }
            WeakMulticastDelegate weakMulticastDelegate  = this.prev;
            WeakMulticastDelegate weakMulticastDelegate2 = this;

            while (weakMulticastDelegate != null)
            {
                if (weakMulticastDelegate.Equals(realDelegate))
                {
                    weakMulticastDelegate2.prev = weakMulticastDelegate.prev;
                    weakMulticastDelegate.prev  = null;
                    break;
                }
                weakMulticastDelegate2 = weakMulticastDelegate;
                weakMulticastDelegate  = weakMulticastDelegate.prev;
            }
            return(this);
        }