示例#1
0
        /*
         * ----< Function > parseJSON
         * ----< Description >
         * Given a JSON file this function will read in the JSON data and parse the data
         * to pull out all relevent information about the dll's and functions within and store
         * the data in a list within the class.
         * ----< Description >
         * @Param StorageFile storageFile -- File object that contains the path / name of the JSON file
         */
        public void parseJSON(StorageFile storageFile)
        {
            Debug.WriteLine(jsonData.ToString());

            JArray  jArray  = (JArray)jsonData["dlls"];
            dynamic dllData = jArray;


            Debug.WriteLine("Testing Dynamics");
            if (dllData != null)
            {
                try
                {
                    foreach (dynamic item in dllData)
                    {
                        dllInfo newDll = new dllInfo();
                        newDll.dllName        = item.Name.ToString();
                        newDll.dllLocation    = item.Location.ToString();
                        newDll.jsonSourceName = storageFile.DisplayName;


                        foreach (dynamic functionT in item.Functions)
                        {
                            dllFunction newFunction = new dllFunction();
                            newFunction.FuncName = functionT.FuncName;
                            newDll.functionList.Add(newFunction);
                        }
                        allDLLData.Add(newDll);
                    }

                    Debug.WriteLine("Testing Listing Function");
                    foreach (dllInfo item in allDLLData)
                    {
                        Debug.WriteLine("Name: " + item.dllName);
                        foreach (dllFunction function in item.functionList)
                        {
                            Debug.WriteLine(function.FuncName);
                        }
                        Debug.WriteLine("---------------------");
                    }
                }catch (Exception ex)
                {
                    GuiLogger.logException("Invalid Source JSON", ex.Message);
                    allDLLData.Clear();
                    return;
                }
            }
            else
            {
                GuiLogger.logException("Invalid Source JSON", "Please Correct");
            }
        }
示例#2
0
        /*
         * ----< Function > DllToggled
         * ----< Description >
         * Once a DLL is toggled the application will call BindDLL(), open a file picker,
         * select the file and bind the physical file to the logic here
         * ----< Description >
         */
        private async void DllToggled(object sender, RoutedEventArgs e)
        {
            int          indexOfCurrentDLLToggled;
            ToggleSwitch toggleSwitch = sender as ToggleSwitch;
            dllInfo      sampleDll    = (dllInfo)((Grid)toggleSwitch.Parent).DataContext;

            Debug.WriteLine(sampleDll.dllName + " Was toggled");

            if (toggleSwitch.IsOn)
            {
                dllBindingClass dllBinder = await BindDLL();

                if (dllBinder != null)
                {
                    Debug.WriteLine("Testing the binder");
                    Debug.WriteLine(dllBinder.dllFullPath + "---" + dllBinder.dllName);

                    Debug.WriteLine("------------");
                    Debug.WriteLine("Before the move: ");
                    indexOfCurrentDLLToggled = fileNamesForListView.IndexOf(sampleDll);
                    if (fileNamesForListView.ElementAt <dllInfo>(indexOfCurrentDLLToggled).dllName == dllBinder.dllName)
                    {
                        Debug.WriteLine(fileNamesForListView.ElementAt <dllInfo>(indexOfCurrentDLLToggled).dllLocation);
                        fileNamesForListView.ElementAt <dllInfo>(indexOfCurrentDLLToggled).dllLocation = dllBinder.dllFullPath;
                        Debug.WriteLine("After the move: ");
                        Debug.WriteLine(fileNamesForListView.ElementAt <dllInfo>(indexOfCurrentDLLToggled).dllLocation);
                    }
                    else
                    {
                        toggleSwitch.IsOn = false;
                        GuiLogger.logException("DLL name in GUI does not match selected DLL file.", "Please Try Again");
                        return;
                    }
                    foreach (dllFunction function in sampleDll.functionList)
                    {
                        function.DllName = fileNamesForListView.ElementAt <dllInfo>(indexOfCurrentDLLToggled).dllName;
                        function.DllPath = fileNamesForListView.ElementAt <dllInfo>(indexOfCurrentDLLToggled).dllLocation;
                        functionForListView.Add(function);
                        this.FunctionList.ItemsSource = functionForListView;
                    }
                }
            }
            else
            {
                foreach (dllFunction function in sampleDll.functionList)
                {
                    functionForListView.Remove(function);
                }
                this.FunctionList.ItemsSource = functionForListView;
            }
        }