System.ComponentModel.DebugReflectEventDescriptor.FillMethods C# (CSharp) Method

FillMethods() private method

private FillMethods ( ) : void
return void
        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.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 = this.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.GetString(SR.ErrorMissingEventAccessors, Name));
                }
            }

            filledMethods = true;
        }