private void AddEventHandlerAtStartOfChain(EventInfo eventInfo, object control, MulticastDelegate recorder) { //this will not work for all events as they are not implemented consistently //TODO: there will be more special cases here eventually. PropertyInfo eventsProp = control.GetType().GetProperty("Events", BindingFlags.NonPublic | BindingFlags.Instance); EventHandlerList handlers = (EventHandlerList)eventsProp.GetValue(control, null); Recorder rec = (Recorder)recorder.Target; FieldInfo eventKey = rec.EventKey(eventInfo.Name); if (eventKey == null) { return; } //actually this should probably allow the exception //most of the time.. this could hide a problem! //TODO: investigate. object key = eventKey.GetValue(control); handlers[key] = Delegate.Combine(recorder, handlers[key]); }