5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) Ximian, Inc. http://www.ximian.com
9 // TODO: Mucho left to implement
13 using System.Runtime.Serialization;
17 public abstract class Delegate : ICloneable, ISerializable {
18 protected Type target_type;
19 protected object m_target;
20 protected string method;
21 protected IntPtr method_ptr;
23 protected Delegate (object target, string method)
26 throw new ArgumentNullException ("Target object is null");
29 throw new ArgumentNullException ("method name is null");
31 this.target_type = null;
32 this.method_ptr = IntPtr.Zero;
33 this.m_target = target;
37 protected Delegate (Type target_type, string method)
40 throw new ArgumentNullException ("Target type is null");
43 throw new ArgumentNullException ("method string is null");
45 this.target_type = target_type;
46 this.method_ptr = IntPtr.Zero;
52 public MethodInfo Method {
59 public object Target {
70 public abstract object Clone ();
72 public override bool Equals (object o)
74 if (!(o is System.Delegate))
77 Delegate d = (Delegate) o;
79 if ((d.target_type == target_type) &&
80 (d.m_target == m_target) &&
87 public override int GetHashCode ()
89 return method.GetHashCode ();
92 // This is from ISerializable
93 public void GetObjectData (SerializationInfo info, StreamingContext context)
98 public static Delegate Combine (Delegate a, Delegate b)
108 if (a.GetType () != b.GetType ())
109 throw new ArgumentException ("Incompatible Delegate Types");
111 return a.CombineImpl (b);
114 protected virtual Delegate CombineImpl (Delegate d)
116 throw new MulticastNotSupportedException ("");