Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reflection to get the Delegate Information

Tags:

c#

reflection

By executing the following i can get the information about methods

Type t=typeof(someType);

MemberInfo[] mInfo = t.GetMethods();

how to get information about delegates declared inside a type?

like image 963
Dina Avatar asked Dec 23 '09 19:12

Dina


1 Answers

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));
}
like image 123
mmx Avatar answered Sep 26 '22 03:09

mmx