New tests.
[mono.git] / mcs / class / corlib / System / MulticastDelegate.cs
index a87f9ad768c54f5a5fb6772c18cdf372a0ceb30e..df7becdea425ed5e4c8ae7e0deabf29e4f4ad6e8 100644 (file)
@@ -36,6 +36,8 @@ using System.Runtime.Serialization;
 
 namespace System
 {
+       [System.Runtime.InteropServices.ComVisible (true)]
+       [Serializable]
        public abstract class MulticastDelegate : Delegate
        {
                private MulticastDelegate prev;
@@ -47,8 +49,8 @@ namespace System
                        prev = null;
                }
 
-               protected MulticastDelegate (Type target_type, string method)
-                       : base (target_type, method)
+               protected MulticastDelegate (Type target, string method)
+                       : base (target, method)
                {
                        prev = null;
                }
@@ -67,17 +69,22 @@ namespace System
                        return base.DynamicInvokeImpl (args);
                }
 
+               internal bool HasSingleTarget {
+                       get { return prev == null; }
+               }
                // <remarks>
                //   Equals: two multicast delegates are equal if their base is equal
                //   and their invocations list is equal.
                // </remarks>
-               public sealed override bool Equals (object o)
+               public sealed override bool Equals (object obj)
                {
-                       if (!base.Equals (o))
+                       if (!base.Equals (obj))
                                return false;
 
-                       MulticastDelegate d = (MulticastDelegate) o;
-
+                       MulticastDelegate d = obj as MulticastDelegate;
+                       if (d == null)
+                               return false;
+                       
                        if (this.prev == null) {
                                if (d.prev == null)
                                        return true;
@@ -139,6 +146,7 @@ namespace System
                                throw new ArgumentException (Locale.GetText ("Incompatible Delegate Types."));
 
                        combined = (MulticastDelegate)follow.Clone ();
+                       combined.SetMulticastInvoke ();
 
                        for (clone = combined, orig = ((MulticastDelegate)follow).prev; orig != null; orig = orig.prev) {
                                
@@ -253,19 +261,20 @@ namespace System
                        return retval;
                }
 
-               public static bool operator == (MulticastDelegate a, MulticastDelegate b)
+               public static bool operator == (MulticastDelegate d1, MulticastDelegate d2)
                {
-                       if ((object)a == null) {
-                               if ((object)b == null)
-                                       return true;
-                               return false;
-                       }
-                       return a.Equals (b);
+                       if (d1 == null)
+                               return d2 == null;
+                               
+                       return d1.Equals (d2);
                }
                
-               public static bool operator != (MulticastDelegate a, MulticastDelegate b)
+               public static bool operator != (MulticastDelegate d1, MulticastDelegate d2)
                {
-                       return !(a == b);
+                       if (d1 == null)
+                               return d2 != null;
+                       
+                       return !d1.Equals (d2);
                }
        }
 }