System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetDefaultEvent C# (CSharp) Method

GetDefaultEvent() private method

Return the default event. The default event is determined by the presence of a DefaultEventAttribute on the class.
private GetDefaultEvent ( object instance ) : System.ComponentModel.EventDescriptor
instance object
return System.ComponentModel.EventDescriptor
            internal EventDescriptor GetDefaultEvent(object instance)
            {
                AttributeCollection attributes;

                if (instance != null)
                {
                    attributes = TypeDescriptor.GetAttributes(instance);
                }
                else
                {
                    attributes = TypeDescriptor.GetAttributes(_type);
                }

                DefaultEventAttribute attr = (DefaultEventAttribute)attributes[typeof(DefaultEventAttribute)];
                if (attr != null && attr.Name != null)
                {
                    if (instance != null)
                    {
                        return TypeDescriptor.GetEvents(instance)[attr.Name];
                    }
                    else
                    {
                        return TypeDescriptor.GetEvents(_type)[attr.Name];
                    }
                }

                return null;
            }