private static void printOutClassesAndMethods(DLLModel dLLModel) { Console.WriteLine("Inside Here" + dLLModel.getFullyQualifiedPath()); Dictionary<string, ClassModel> allClassesInDll = dLLModel.getAllClassesInThisDll(); foreach(KeyValuePair<string, ClassModel> pair in allClassesInDll) { ClassModel classAtHand = pair.Value; Console.WriteLine("-------------------------------------------"); Console.WriteLine(""); Console.WriteLine("Class ---> " + classAtHand.getClassName()); Console.WriteLine(""); Console.WriteLine("-------------------------------------------"); Console.WriteLine(""); Console.WriteLine("Methods in this class"); Console.WriteLine(""); Console.WriteLine("-------------------------------------------"); SortedList<string, MethodModel> methodsInClass = classAtHand.getAllMethodsInThisClass(); foreach (KeyValuePair<string, MethodModel> methodPair in methodsInClass) { MethodModel methodAtHand = methodPair.Value; Console.WriteLine(" Returns " + methodAtHand.getMethodReturnType() + "-----" + '\t' + methodAtHand.getShortenedName() ); } Console.WriteLine(""); Console.WriteLine(""); } }
public static DLLModel populateUserSelectedClassesAndMethods(DLLModel dllAtHand) { string userAddedClassesAndMethods = ConfigurationManager.AppSettings["methodsToAdd"]; if (userAddedClassesAndMethods == null) { Console.WriteLine("Incorrect configuration, methodsToAdd property not present."); Environment.Exit(0); } string[] colonSeparatedStrings = userAddedClassesAndMethods.Split(';'); for (int i = 0; i < colonSeparatedStrings.Length; i++) { string methodAtHandString = colonSeparatedStrings[i]; Dictionary<string, ClassModel> classesInDll = dllAtHand.getAllClassesInThisDll(); foreach (KeyValuePair<string, ClassModel> pair in classesInDll) { ClassModel classAtHand = pair.Value; if (classAtHand.getAllMethodsInThisClass().ContainsKey(methodAtHandString)) { int indexOfMethodToBeFetched = classAtHand.getAllMethodsInThisClass().IndexOfKey(methodAtHandString); classAtHand.getUserSelectedMethodsInThisClass().Add(methodAtHandString, classAtHand.getAllMethodsInThisClass().ElementAt(indexOfMethodToBeFetched).Value); //Now add this class to the DLL's user selected methods, no duplicates if (!dllAtHand.getUserSelectedClassesInThisDll().ContainsKey(classAtHand.getClassName())) { dllAtHand.getUserSelectedClassesInThisDll().Add(classAtHand.getClassName(), classAtHand); } } } } return dllAtHand; }
public DLLModel processDLL(DLLModel dLLAtHand) { if (!dLLAtHand.isDLLManaged()) { dLLAtHand = convertDLLToManaged(dLLAtHand); } Console.WriteLine(dLLAtHand.ToString()); Console.WriteLine(dLLAtHand.getFullyQualifiedPath()); Assembly dLLAssembly = Assembly.LoadFile(dLLAtHand.getFullyQualifiedPath()); foreach (Type memberType in dLLAssembly.GetTypes()) { int i = 0; if (memberType.IsClass) { i++; ClassModel classAtHand = new ClassModel(memberType.FullName); this.extractMethodsFromClass(classAtHand, memberType); classAtHand.setDllThisClassBelongsTo(dLLAtHand); dLLAtHand.getAllClassesInThisDll().Add(classAtHand.getClassName(), classAtHand); } } return dLLAtHand; }