コード例 #1
0
ファイル: EventTarget.cs プロジェクト: vrajeshbhavsar/mcjs
        public static EventListeners GetEventListeners(mdr.DObject obj, string eventName)
        {
            Debug.Assert(obj != null, "invalid null object for adding event '{0}' listener", eventName);
            var pd = obj.GetPropertyDescriptor(eventName);

            Debug.Assert(pd != null, "cannot find property descriptor for event {0}", eventName);
            Debug.Assert(pd.IsAccessorDescriptor && pd.IsInherited, "invalid property descriptor type {0} for event {1}", pd.GetAttributes(), eventName);
            // Debug.Assert(pd.IsAccessorDescriptor, "invalid property discriptor type {0} for event {1}", pd.GetAttributes(), eventName);
            var eventHandler = pd.GetProperty() as EventHandlerProperty;

            Debug.Assert(eventHandler != null, "invalid event handler at index {0}", pd.Index);
            var eventTarget = obj as EventTarget;

            Debug.Assert(eventTarget != null, "Invalid event target object type {0}", obj.GetType().FullName);
            if (eventHandler == null || eventTarget == null)
            {
                return(null);
            }
            var eventListeners = eventTarget.GetEventListeners(eventHandler.EventType, true);

            return(eventListeners);
        }