开发者

Reflection to get the Delegate Information

开发者 https://www.devze.com 2022-12-14 14:59 出处:网络
By executing the following i can get the information about methods Type t=typeof(someType开发者_StackOverflow社区);

By executing the following i can get the information about methods

Type t=typeof(someType开发者_StackOverflow社区);

MemberInfo[] mInfo = t.GetMethods();

how to get information about delegates declared inside a type?


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

精彩评论

暂无评论...
验证码 换一张
取 消