/** * Return the methods in dll file * */ public static List<TestCommand> GetAllMethodsDLLs(string dllPath) { Assembly _Assemblies = null; try { _Assemblies = Assembly.LoadFrom(dllPath); } catch (Exception ex) { Console.WriteLine("\n\nError - couldn't obtain assemblies from " + dllPath); Console.WriteLine("EXCEPTION OUTPUT\n" + ex.Message + "\n" + ex.InnerException); } List<TestCommand> _Temp = new List<TestCommand>(); if (_Assemblies != null) { Type[] _AllTypes = _Assemblies.GetTypes(); foreach (Type t in _AllTypes) { int i = 0; MethodInfo[] Methods = t.GetMethods(); foreach (MethodInfo meth in Methods) { bool flag = false; object[] attributes = meth.GetCustomAttributes(false); if (attributes.Length > 0) { foreach (var item in attributes) { List<string> _temp = util.getListValueWithToken(item.ToString(), '.'); int n = _temp.Count; string AttributeName = ""; if (n > 1) { AttributeName = _temp[n-1]; } if (AttributeName.Equals("Automation")) { flag = true; } } } if (flag) { i++; TestCommand temp = new TestCommand(); temp.Object = dllPath; temp.Target = t.ToString(); string function = getFunc(meth); temp.Function = function; temp.Keyword = meth.Name; _Temp.Add(temp); } } } } return _Temp; }
public List<TestCommand> getTestCommands() { List<TestCommand> rs = new List<TestCommand>(); foreach (var item in _xElement.Elements("TestCommand")) { TestCommand temp = new TestCommand(); temp.Keyword = item.Attribute("Keyword").Value; temp.Object = item.Attribute("Object").Value; temp.Target = item.Attribute("Target").Value; temp.Function = item.Attribute("Function").Value; temp.ID = item.Attribute("ID").Value; rs.Add(temp); } return rs; }