Friday, June 27, 2014

How to create a sorted list of methods with parameters and datatypes and add them to treeview

var query = from m in typeof(AbolWebServiceClient).GetMethods()
            orderby m.Name
            where   m.IsPublic == true &&
                    m.Name.Contains("Async")==false &&
                    m.IsSecurityCritical==true
            select m;

foreach (MethodInfo method in query)
{
    TreeNode tnMethod = treeViewMethods.Nodes.Add(method.Name);
    foreach(var param in method.GetParameters())
    {
        tnMethod.Nodes.Add(String.Format("{0} {1}", param.ParameterType.Name, param.Name));
    }

}