2 // System.MultiCastDelegate.cs
5 // Miguel de Icaza (miguel@ximian.com)
6 // Daniel Stodden (stodden@in.tum.de)
8 // (C) Ximian, Inc. http://www.ximian.com
10 // TODO: Remove Missing
13 using System.Globalization;
17 public abstract class MulticastDelegate : Delegate
19 private MulticastDelegate prev;
21 protected MulticastDelegate (object target, string method)
22 : base (target, method)
27 protected MulticastDelegate (Type target_type, string method)
28 : base (target_type, method)
34 private MulticastDelegate (Type target_type, string method, Delegate [] list)
35 : base (target_type, method)
37 invocation_list = (Delegate[])list.Clone ();
42 public MethodInfo Method {
49 public override object DynamicInvokeImpl( object[] args )
52 prev.DynamicInvokeImpl( args );
54 return base.DynamicInvokeImpl( args );
58 // Equals: two multicast delegates are equal if their base is equal
59 // and their invocations list is equal.
61 public override bool Equals (object o)
63 if ( ! base.Equals( o ) )
66 MulticastDelegate d = this;
67 MulticastDelegate c = (MulticastDelegate) o;
74 } while ( (object)d != null );
76 if ( (object)c == null )
83 // FIXME: This could use some improvements.
85 public override int GetHashCode ()
87 return base.GetHashCode ();
91 // Return, in order of invocation, the invocation list
92 // of a MulticastDelegate
94 public override Delegate[] GetInvocationList()
96 throw new NotImplementedException();
100 // Combines this MulticastDelegate with the (Multicast)Delegate `follow'.
101 // This does _not_ combine with Delegates. ECMA states the whole delegate
102 // thing should have better been a simple System.Delegate class.
103 // Compiler generated delegates are always MulticastDelegates.
105 protected override Delegate CombineImpl( Delegate follow )
107 MulticastDelegate combined, orig, clone;
109 if ( this.GetType() != follow.GetType() )
110 throw new ArgumentException( Locale.GetText("Incompatible Delegate Types") );
112 combined = (MulticastDelegate)follow.Clone();
114 for ( clone = combined, orig = ((MulticastDelegate)follow).prev;
115 (object)orig != null; orig = orig.prev ) {
117 clone.prev = (MulticastDelegate)orig.Clone();
121 clone.prev = (MulticastDelegate)this.Clone();
123 for ( clone = clone.prev, orig = this.prev;
124 (object)orig != null; orig = orig.prev ) {
126 clone.prev = (MulticastDelegate)orig.Clone();
133 protected override Delegate RemoveImpl( Delegate value )
135 throw new NotImplementedException();