private EventToGenerate[] CollectEvents(ArrayList methodList, Type type, bool onlyVirtuals, ClassEmitter emitter) { ArrayList toGenerateList = new ArrayList(); BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; EventInfo[] events = type.GetEvents(flags); foreach(EventInfo eventInfo in events) { MethodInfo addMethod = eventInfo.GetAddMethod(true); MethodInfo removeMethod = eventInfo.GetRemoveMethod(true); bool shouldGenerate = false; if (addMethod != null && IsAccessible(addMethod) && AcceptMethod(addMethod, onlyVirtuals)) { shouldGenerate = true; methodList.Add(addMethod); } if (removeMethod != null && IsAccessible(removeMethod) && AcceptMethod(removeMethod, onlyVirtuals)) { shouldGenerate = true; methodList.Add(removeMethod); } if (shouldGenerate == false) continue; EventAttributes atts = ObtainEventAttributes(eventInfo); EventEmitter eventEmitter = emitter.CreateEvent(eventInfo.Name, atts, eventInfo.EventHandlerType); EventToGenerate eventToGenerate = new EventToGenerate(eventEmitter, addMethod, removeMethod, atts); toGenerateList.Add(eventToGenerate); } return (EventToGenerate[]) toGenerateList.ToArray(typeof(EventToGenerate)); }