2002-01-14 Miguel de Icaza <miguel@ximian.com>
[mono.git] / mcs / class / corlib / System / MulticastDelegate.cs
1 //
2 // System.MultiCastDelegate.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.Globalization;
13 namespace System {
14
15         public abstract class MulticastDelegate : Delegate {
16
17                 Delegate [] invocation_list;
18                 
19                 protected MulticastDelegate (object target, string method)
20                         : base (target, method)
21                 {
22                         invocation_list = null;
23                 }
24
25                 protected MulticastDelegate (Type target_type, string method)
26                         : base (target_type, method)
27                 {
28                         invocation_list = null;
29                 }
30
31                 private MulticastDelegate (Type target_type, string method, Delegate [] list)
32                         : base (target_type, method)
33                 {
34                         invocation_list = list;
35                 }
36                 
37 #if NOTYET
38                 public MethodInfo Method {
39                         get {
40                                 return null;
41                         }
42                 }
43 #endif
44
45                 // <remarks>
46                 //   Equals: two multicast delegates are equal if their base is equal
47                 //   and their invocations list is equal.
48                 // </remarks>
49                 public override bool Equals (object o)
50                 {
51                         if (!(o is System.MulticastDelegate))
52                                 return false;
53
54                         if (!base.Equals (o))
55                                 return false;
56
57                         MulticastDelegate d = (MulticastDelegate) o;
58
59                         if (d.invocation_list == null){
60                                 if (invocation_list == null)
61                                         return true;
62                                 return false;
63                         } else if (invocation_list == null)
64                                 return false;
65
66                         int i = 0;
67                         foreach (Delegate del in invocation_list){
68                                 if (del != d.invocation_list [i++])
69                                         return false;
70                         }
71                         
72                         return true;
73                 }
74
75                 //
76                 // FIXME: This could use some improvements.
77                 //
78                 public override int GetHashCode ()
79                 {
80                         return base.GetHashCode ();
81                 }
82
83                 // <summary>
84                 //   Combines this MulticastDelegate with the Delegate `follow'.
85                 //   This can combine MulticastDelegates and Delegates
86                 // </summary>
87                 [MonoTODO]
88                 protected override Delegate CombineImpl (Delegate follow)
89                 {
90                         
91                         throw new NotImplementedException ();
92
93                         // FIXME: Implement me.
94                         // This is not as simple to implement, as we can
95                         // not create an instance of MulticastDelegate.
96                         //
97                         // Got to think more about this.
98                 }
99
100                 [MonoTODO]
101                 public static bool operator == (MulticastDelegate a, MulticastDelegate b) {
102                         throw new NotImplementedException ();
103                 }
104                 [MonoTODO]
105                 public static bool operator != (MulticastDelegate a, MulticastDelegate b) {
106                         throw new NotImplementedException ();
107                 }
108         }
109 }