Reflection to get the Delegate Information

前端 未结 1 886
猫巷女王i
猫巷女王i 2021-01-02 10:33

By executing the following i can get the information about methods

Type t=typeof(someType);

MemberInfo[] mInfo = t.GetMethods();

how to ge

相关标签:
1条回答
  • 2021-01-02 11:23

    Call Type.GetNestedTypes to get the nested types and filter them by being a delegate (check whether they inherit from System.MulticastDelegate):

    static IEnumerable<Type> GetNestedDelegates(Type type)
    {
        return type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic)
                   .Where(t => t.BaseType == typeof(MulticastDelegate));
    }
    
    0 讨论(0)
提交回复
热议问题