This is not too hard to do.
You need to use
System.Reflection
. See this name space for more information.
Here is what you basically do:
Type interfaceType = typeof(IMyInterface);
System.Reflection.BindingFlags flags =
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.NonPublic;
System.Reflection.PropertyInfo[] properties = interfaceType.GetProperties(flags);
System.Reflection.MethodInfo[] methods = interfaceType.GetMethods(flags);
As some further step, you can reflect all properties accessors as methods, for all methods reflect parameters and their type and so on.
The real question is why? John is right.
It would makes sense for class or structure. In this case you could construct the object and invoke method. It make no sense for interface. You can only instantiate any object if you have structure or class implementing this interface. The code I show may make some sense if you also reflect a class or a structure.
—SA