EventInfo[] GetEventsInternal (BindingFlags bf, MonoGenericClass reftype) {
TypeBuilder tb = generic_type as TypeBuilder;
if (tb == null) {
EventInfo[] res = generic_type.GetEvents (bf);
for (int i = 0; i < res.Length; ++i)
res [i] = new EventOnTypeBuilderInst (this, res [i]);
return res;
}
EventBuilder[] events = tb.events;
if (events == null || events.Length == 0)
return new EventInfo [0];
initialize ();
ArrayList l = new ArrayList ();
bool match;
MethodAttributes mattrs;
MethodInfo accessor;
for (int i = 0; i < event_count; ++i) {
EventBuilder ev = events [i];
match = false;
accessor = ev.add_method;
if (accessor == null)
accessor = ev.remove_method;
if (accessor == null)
continue;
mattrs = accessor.Attributes;
if ((mattrs & MethodAttributes.MemberAccessMask) == MethodAttributes.Public) {
if ((bf & BindingFlags.Public) != 0)
match = true;
} else {
if ((bf & BindingFlags.NonPublic) != 0)
match = true;
}
if (!match)
continue;
match = false;
if ((mattrs & MethodAttributes.Static) != 0) {
if ((bf & BindingFlags.Static) != 0)
match = true;
} else {
if ((bf & BindingFlags.Instance) != 0)
match = true;
}
if (!match)
continue;
l.Add (new EventOnTypeBuilderInst (this, ev));
}
EventInfo[] result = new EventInfo [l.Count];
l.CopyTo (result);
return result;
}