コード例 #1
0
        /// <summary>Returns the invocation list of this multicast delegate, in invocation order.</summary>
        /// <returns>An array of delegates whose invocation lists collectively match the invocation list of this instance.</returns>
        /// <exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism. </exception>
        /// <filterpriority>2</filterpriority>
        public sealed override Delegate[] GetInvocationList()
        {
            MulticastDelegate multicastDelegate = (MulticastDelegate)this.Clone();

            multicastDelegate.kpm_next = null;
            while (multicastDelegate.prev != null)
            {
                multicastDelegate.prev.kpm_next = multicastDelegate;
                multicastDelegate = multicastDelegate.prev;
            }
            if (multicastDelegate.kpm_next == null)
            {
                MulticastDelegate multicastDelegate2 = (MulticastDelegate)multicastDelegate.Clone();
                multicastDelegate2.prev     = null;
                multicastDelegate2.kpm_next = null;
                return(new Delegate[]
                {
                    multicastDelegate2
                });
            }
            ArrayList arrayList = new ArrayList();

            while (multicastDelegate != null)
            {
                MulticastDelegate multicastDelegate3 = (MulticastDelegate)multicastDelegate.Clone();
                multicastDelegate3.prev     = null;
                multicastDelegate3.kpm_next = null;
                arrayList.Add(multicastDelegate3);
                multicastDelegate = multicastDelegate.kpm_next;
            }
            return((Delegate[])arrayList.ToArray(typeof(Delegate)));
        }
コード例 #2
0
        /// <summary>Combines this <see cref="T:System.Delegate" /> with the specified <see cref="T:System.Delegate" /> to form a new delegate.</summary>
        /// <returns>A <see cref="T:System.Delegate" /> that is the new root of the <see cref="T:System.MulticastDelegate" /> invocation list.</returns>
        /// <param name="follow">The delegate to combine with this delegate. </param>
        /// <exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism. </exception>
        protected sealed override Delegate CombineImpl(Delegate follow)
        {
            if (base.GetType() != follow.GetType())
            {
                throw new ArgumentException(Locale.GetText("Incompatible Delegate Types."));
            }
            MulticastDelegate multicastDelegate = (MulticastDelegate)follow.Clone();

            multicastDelegate.SetMulticastInvoke();
            MulticastDelegate multicastDelegate2 = multicastDelegate;

            for (MulticastDelegate multicastDelegate3 = ((MulticastDelegate)follow).prev; multicastDelegate3 != null; multicastDelegate3 = multicastDelegate3.prev)
            {
                multicastDelegate2.prev = (MulticastDelegate)multicastDelegate3.Clone();
                multicastDelegate2      = multicastDelegate2.prev;
            }
            multicastDelegate2.prev = (MulticastDelegate)this.Clone();
            multicastDelegate2      = multicastDelegate2.prev;
            for (MulticastDelegate multicastDelegate3 = this.prev; multicastDelegate3 != null; multicastDelegate3 = multicastDelegate3.prev)
            {
                multicastDelegate2.prev = (MulticastDelegate)multicastDelegate3.Clone();
                multicastDelegate2      = multicastDelegate2.prev;
            }
            return(multicastDelegate);
        }
コード例 #3
0
        /// <summary>Removes an element from the invocation list of this <see cref="T:System.MulticastDelegate" /> that is equal to the specified delegate.</summary>
        /// <returns>If <paramref name="value" /> is found in the invocation list for this instance, then a new <see cref="T:System.Delegate" /> without <paramref name="value" /> in its invocation list; otherwise, this instance with its original invocation list.</returns>
        /// <param name="value">The delegate to search for in the invocation list. </param>
        /// <exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism. </exception>
        protected sealed override Delegate RemoveImpl(Delegate value)
        {
            if (value == null)
            {
                return(this);
            }
            MulticastDelegate multicastDelegate2;
            MulticastDelegate multicastDelegate = MulticastDelegate.KPM((MulticastDelegate)value, this, out multicastDelegate2);

            if (multicastDelegate == null)
            {
                return(this);
            }
            MulticastDelegate multicastDelegate3 = null;
            MulticastDelegate result             = null;

            for (MulticastDelegate multicastDelegate4 = this; multicastDelegate4 != multicastDelegate; multicastDelegate4 = multicastDelegate4.prev)
            {
                MulticastDelegate multicastDelegate5 = (MulticastDelegate)multicastDelegate4.Clone();
                if (multicastDelegate3 != null)
                {
                    multicastDelegate3.prev = multicastDelegate5;
                }
                else
                {
                    result = multicastDelegate5;
                }
                multicastDelegate3 = multicastDelegate5;
            }
            for (MulticastDelegate multicastDelegate4 = multicastDelegate2; multicastDelegate4 != null; multicastDelegate4 = multicastDelegate4.prev)
            {
                MulticastDelegate multicastDelegate6 = (MulticastDelegate)multicastDelegate4.Clone();
                if (multicastDelegate3 != null)
                {
                    multicastDelegate3.prev = multicastDelegate6;
                }
                else
                {
                    result = multicastDelegate6;
                }
                multicastDelegate3 = multicastDelegate6;
            }
            if (multicastDelegate3 != null)
            {
                multicastDelegate3.prev = null;
            }
            return(result);
        }