System.Type.GetEvent C# (CSharp) Method

GetEvent() public method

public GetEvent ( string name ) : EventInfo
name string
return EventInfo
        public EventInfo GetEvent(string name)
        {
            foreach (var eventInfo in GetEvents())
            {
                if (eventInfo.Name == name)
                    return eventInfo;
            }
            return null;
        }

Usage Example

Beispiel #1
0
    public static EventInfo GetStaticEventInfo(System.Type type, string eventName)
    {
        var       flags = BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
        EventInfo ei    = type.GetEvent(eventName, flags);

        while (ei == null && type.BaseType != null)
        {
            type = type.BaseType;
            ei   = type.GetEvent(eventName, flags);
        }

        return(ei);
    }
All Usage Examples Of System.Type::GetEvent