private void FillMethods()
{
if (_filledMethods) return;
if (_realEvent != null)
{
_addMethod = _realEvent.GetAddMethod();
_removeMethod = _realEvent.GetRemoveMethod();
EventInfo defined = null;
if (_addMethod == null || _removeMethod == null)
{
Type start = _componentClass.GetTypeInfo().BaseType;
while (start != null && start != typeof(object))
{
BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
EventInfo test = start.GetEvent(_realEvent.Name, bindingFlags);
if (test.GetAddMethod() != null)
{
defined = test;
break;
}
}
}
if (defined != null)
{
_addMethod = defined.GetAddMethod();
_removeMethod = defined.GetRemoveMethod();
_type = defined.EventHandlerType;
}
else
{
_type = _realEvent.EventHandlerType;
}
}
else
{
// first, try to get the eventInfo...
//
_realEvent = _componentClass.GetEvent(Name);
if (_realEvent != null)
{
// if we got one, just recurse and return.
//
FillMethods();
return;
}
Type[] argsType = new Type[] { _type };
_addMethod = FindMethod(_componentClass, "AddOn" + Name, argsType, typeof(void));
_removeMethod = FindMethod(_componentClass, "RemoveOn" + Name, argsType, typeof(void));
if (_addMethod == null || _removeMethod == null)
{
Debug.Fail("Missing event accessors for " + _componentClass.FullName + "." + Name);
throw new ArgumentException(SR.Format(SR.ErrorMissingEventAccessors, Name));
}
}
_filledMethods = true;
}