dump the public methods of a class
using System;
using System.Reflection;
class DumpType {
static void Main(string[] argv) {
targetType = LoadAssembly(argv[0], argv[1]);
DumpReportHeader();
DumpMethods();
}
static public Type LoadAssembly(string t, string a) {
return Type.ReflectionOnlyGetType(t + "," + a, false, true);
}
static void DumpReportHeader() {
Console.WriteLine("\n{0} type of {1} assembly",targetType.Name, targetType.Assembly.GetName().Name);
Console.WriteLine("\n{0,22}\n", "[ METHODS ]");
}
static void DumpMethods() {
string dashes = new string('-', 50);
foreach (MethodInfo method in targetType.GetMethods()) {
Console.WriteLine("{0,12}{1,-12}", " ", method.Name + " " + "<" + method.ReturnParameter.ParameterType.Name + ">");
int count = 1;
foreach (ParameterInfo parameter in method.GetParameters()) {
Console.WriteLine("{0, 35}{1, -12}"," ", (count++).ToString() + " " + parameter.Name + " (" + parameter.ParameterType.Name + ")");
}
Console.WriteLine("{0,12}{1}", " ", dashes);
}
}
private static Type targetType;
}
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
-
|
|