Author: jackson
Date: 2005-03-03 05:08:57 -0500 (Thu, 03 Mar 2005)
New Revision: 41388

Modified:
   trunk/mcs/class/System/System.ComponentModel/ChangeLog
   trunk/mcs/class/System/System.ComponentModel/ReflectionEventDescriptor.cs
Log:
        * ReflectionEventDescriptor.cs: Bind handlers to the actual event so 
that
        the delegates get invoked when the methods are.



Modified: trunk/mcs/class/System/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ChangeLog      2005-03-03 
09:25:16 UTC (rev 41387)
+++ trunk/mcs/class/System/System.ComponentModel/ChangeLog      2005-03-03 
10:08:57 UTC (rev 41388)
@@ -1,5 +1,10 @@
 2005-03-02  Jackson Harper  <[EMAIL PROTECTED]>
 
+       * ReflectionEventDescriptor.cs: Bind handlers to the actual event so 
that
+       the delegates get invoked when the methods are.
+
+2005-03-02  Jackson Harper  <[EMAIL PROTECTED]>
+
        * EventDescriptorCollection.cs: Handle null in the constructor properly.
 
 2005-02-12  Geoff Norton  <[EMAIL PROTECTED]>

Modified: 
trunk/mcs/class/System/System.ComponentModel/ReflectionEventDescriptor.cs
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ReflectionEventDescriptor.cs   
2005-03-03 09:25:16 UTC (rev 41387)
+++ trunk/mcs/class/System/System.ComponentModel/ReflectionEventDescriptor.cs   
2005-03-03 10:08:57 UTC (rev 41388)
@@ -4,9 +4,8 @@
 // Authors:
 //  Lluis Sanchez Gual ([EMAIL PROTECTED])
 //
-// (C) Novell, Inc. 2004
+// (C) Novell, Inc. 2004, 2005
 //
-
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -37,28 +36,41 @@
 {
        internal class ReflectionEventDescriptor: EventDescriptor
        {
-               Hashtable handlers;
                Type _eventType;
                Type _componentType;
                EventInfo _eventInfo;
-               
+
+               MethodInfo add_method;
+               MethodInfo remove_method;
+
                public ReflectionEventDescriptor (EventInfo eventInfo) : base 
(eventInfo.Name, (Attribute[]) eventInfo.GetCustomAttributes (true))
                {
                        _eventInfo = eventInfo;
                        _componentType = eventInfo.DeclaringType;
                        _eventType = eventInfo.EventHandlerType;
+
+                       add_method = eventInfo.GetAddMethod ();
+                       remove_method = eventInfo.GetRemoveMethod ();
                }
 
                public ReflectionEventDescriptor (Type componentType, 
EventDescriptor oldEventDescriptor, Attribute[] attrs) : base 
(oldEventDescriptor, attrs)
                {
                        _componentType = componentType;
                        _eventType = oldEventDescriptor.EventType;
+
+                       EventInfo event_info = componentType.GetEvent 
(oldEventDescriptor.Name);
+                       add_method = event_info.GetAddMethod ();
+                       remove_method = event_info.GetRemoveMethod ();
                }
 
                public ReflectionEventDescriptor (Type componentType, string 
name, Type type, Attribute[] attrs) : base (name, attrs)
                {
                        _componentType = componentType;
                        _eventType = type;
+
+                       EventInfo event_info = componentType.GetEvent (name);
+                       add_method = event_info.GetAddMethod ();
+                       remove_method = event_info.GetRemoveMethod ();
                }
                
                EventInfo GetEventInfo ()
@@ -73,27 +85,12 @@
 
                public override void AddEventHandler (object component, 
System.Delegate value)
                {
-                       if (handlers == null)
-                               handlers = new Hashtable ();
-                       
-                       ArrayList delegates = (ArrayList) handlers [component];
-                       if (delegates == null) {
-                               delegates = new ArrayList ();
-                               handlers [component] = delegates;
-                       }
-                       
-                       if (!delegates.Contains (value))
-                               delegates.Add (value);
+                       add_method.Invoke (component, new object [] { value });
                }
 
                public override void RemoveEventHandler (object component, 
System.Delegate value)
                {
-                       if (handlers == null) return;
-                       
-                       ArrayList delegates = (ArrayList) handlers [component];
-                       if (delegates == null) return;
-                       
-                       delegates.Remove (value);
+                       remove_method.Invoke (component, new object [] { value 
});
                }
 
                public override System.Type ComponentType

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to