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("");
            }
        }
Example #2
0
        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;
        }
Example #3
0
 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;
 }
Example #4
0
        public static DLLModel populateUserSelectedClassesAndMethods(DLLModel dllAtHand)
        {
            string userAddedClassesAndMethods = PropertyUtil.getUserSelectedMethods();
            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];
                string tmpStringForSplit = new string(methodAtHandString.ToCharArray());
                string[] controllerAndActionAliases = tmpStringForSplit.Split(PropertyUtil.methodAndAliasSeparator);
                Boolean aliasesExist = false;
                string controllerAlias = null;
                string actionAlias = null;

                if (controllerAndActionAliases.Length > 1)
                {
                    //Aliases Exist, time to fetch them
                    aliasesExist = true;
                    string[] individualAliasNames = controllerAndActionAliases[1].Split(PropertyUtil.aliasSeparator);
                    controllerAlias = individualAliasNames[0];
                    actionAlias = individualAliasNames[1];

                    //Lest we pass the method name along with the aliases
                    methodAtHandString = controllerAndActionAliases[0];
                }
                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);
                        MethodModel methodAtHand = classAtHand.getAllMethodsInThisClass().ElementAt(indexOfMethodToBeFetched).Value;
                        if (aliasesExist)
                        {
                            methodAtHand.setAliasName(actionAlias);
                            classAtHand.setAliasName(controllerAlias);
                        }
                        classAtHand.getUserSelectedMethodsInThisClass().Add(methodAtHandString,
                            methodAtHand);
                        //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;
        }