Listing Types and Methods of assembly, Reflection
Some time there can be requirment in which we need to list the types and methods of assembly. For that purpose we have to use the reflection with help of that we can get all the details of the assembly even the IL code also. one samle to list the Types, associated methods and there properties is given below
//Get the assembly object
Assembly assembly = Assembly.LoadFrom(openFileDlg.FileName);
//List them all
foreach (Type type in assembly.GetTypes())
{
//Create a node of types first
TreeNodetreeNode = assemblyTreeView.Nodes.Add(type.Name);
foreach (MethodInfo mthdInfo in type.GetMethods())
{
//Get the node as method name
TreeNodemethodNode = treeNode.Nodes.Add(mthdInfo.Name);
//List the details of the method as child node
methodNode.Nodes.Add("Return Type : " +
mthdInfo.ReturnType.ToString());
methodNode.Nodes.Add("IsAbstract : " +
mthdInfo.IsAbstract.ToString());
methodNode.Nodes.Add("Access Modifier : " +
(mthdInfo.IsPublic ? "Public" : "Private"));
methodNode.Nodes.Add("IsStatic : " +
mthdInfo.IsStatic.ToString());
}
}
It is not limited to this much even you can create a type out of it and even can invoke methods of those type. This can be very useful when you want to create instance of class at runtime after locating in the various assemblies
Подскажите шооблончег под WordPress 2.6.2, чтобы был похож на ваш towardsnext.wordpress.com.
Заранее благодарю)