[Mono-bugs] [Bug 651561] ReflectionPropertyDescriptor.AddValueChanged doesn't use object property xxxChanged events

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Nov 4 20:13:53 EDT 2010


https://bugzilla.novell.com/show_bug.cgi?id=651561

https://bugzilla.novell.com/show_bug.cgi?id=651561#c1


--- Comment #1 from Clinton Volzke <cvolzke at live.com.au> 2010-11-05 00:13:52 UTC ---
To fix, add this code to ReflectionPropertyDescriptor:

        public override void AddValueChanged(object component, EventHandler
handler)
        {
            if (PropertyChangedEvent != null &&
PropertyChangedEvent.EventType.IsInstanceOfType(handler))
            {
                PropertyChangedEvent.AddEventHandler(component, handler);
            }
            else
            {
                base.AddValueChanged(component, handler);
            }
        }

        public override void RemoveValueChanged(object component, EventHandler
handler)
        {
            if (PropertyChangedEvent != null &&
PropertyChangedEvent.EventType.IsInstanceOfType(handler))
            {
                PropertyChangedEvent.RemoveEventHandler(component, handler);
            }
            else
            {
                base.RemoveValueChanged(component, handler);
            }
        }

        private bool propertyChangedEventQueried;
        private EventDescriptor propertyChangedEvent;
        private EventDescriptor PropertyChangedEvent
        {
            get
            {
                if (!propertyChangedEventQueried)
                {
                    propertyChangedEventQueried = true;
                    propertyChangedEvent =
TypeDescriptor.GetEvents(ComponentType)[Name + "Changed"];
                }
                return propertyChangedEvent;
            }
        }

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list