2001-08-01 Dietmar Maurer <dietmar@ximian.com>
[mono.git] / mcs / class / corlib / System / Delegate.cs
1 //
2 // System.Delegate.cs
3 //
4 // Author:
5 //   Miguel de Icaza (miguel@ximian.com)
6 //
7 // (C) Ximian, Inc.  http://www.ximian.com
8 //
9 // TODO:  Mucho left to implement
10 //
11
12 using System;
13 using System.Runtime.Serialization;
14
15 namespace System {
16
17         public abstract class Delegate : ICloneable, ISerializable {
18                 protected Type target_type;
19                 protected object target;
20                 protected string method;
21                 
22                 protected Delegate (object target, string method)
23                 {
24                         if (target == null)
25                                 throw new ArgumentNullException ("Target object is null");
26
27                         if (method == null)
28                                 throw new ArgumentNullException ("method name is null");
29
30                         this.target_type = null;
31                         this.target = target;
32                         this.method = method;
33                 }
34
35                 protected Delegate (Type target_type, string method)
36                 {
37                         if (target == null)
38                                 throw new ArgumentNullException ("Target type is null");
39
40                         if (method == null)
41                                 throw new ArgumentNullException ("method string is null");
42
43                         this.target_type = target_type;
44                         this.target = null;
45                         this.method = method;
46                 }
47
48 #if NOTYET
49                 public MethodInfo Method {
50                         get {
51                                 return null;
52                         }
53                 }
54 #endif
55
56                 public object Target {
57                         get {
58                                 return target;
59                         }
60                 }
61
62
63                 //
64                 // Methods
65                 //
66
67                 public abstract object Clone ();
68
69                 public override bool Equals (object o)
70                 {
71                         if (!(o is System.Delegate))
72                                 return false;
73
74                         Delegate d = (Delegate) o;
75                         
76                         if ((d.target_type == target_type) &&
77                             (d.target == target) &&
78                             (d.method == method))
79                                 return true;
80
81                         return false;
82                 }
83
84                 public override int GetHashCode ()
85                 {
86                         return method.GetHashCode ();
87                 }
88
89                 // This is from ISerializable
90                 public void GetObjectData (SerializationInfo info, StreamingContext context)
91                 {
92                         // TODO: IMPLEMENT ME
93                 }
94                 
95         }
96 }