importing messaging-2008 branch to trunk [continued]
[mono.git] / mcs / class / System.Web / System.Web.UI / DataBindingCollection.cs
index c919e35af0c8ad5bddde3f53828f8d7a753be797..c7adf86caacff7567ecc7a51193fe84cb2692354 100644 (file)
@@ -26,6 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System.ComponentModel;
 using System.Collections;
 using System.Security.Permissions;
 
@@ -35,8 +36,20 @@ namespace System.Web.UI {
        [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        public sealed class DataBindingCollection : ICollection, IEnumerable
        {
+               static readonly object changedEvent = new object ();
                Hashtable list;
                ArrayList removed;
+
+               EventHandlerList events = new EventHandlerList ();
+#if NET_2_0
+               public 
+#else
+               internal
+#endif
+               event EventHandler Changed {
+                       add { events.AddHandler (changedEvent, value); }
+                       remove { events.RemoveHandler (changedEvent, value); }
+               }
                
                public DataBindingCollection ()
                {
@@ -118,15 +131,13 @@ namespace System.Web.UI {
                {
                        return list.Contains (propertyName);
                }
-
-               public event EventHandler Changed;
-#else
-               internal event EventHandler Changed;
 #endif
+
                internal void RaiseChanged ()
                {
-                       if (Changed != null)
-                               Changed (this, EventArgs.Empty);
+                       EventHandler eh = events [changedEvent] as EventHandler;
+                       if (eh != null)
+                               eh (this, EventArgs.Empty);
                }
        }
 }