public MainWindow() { InitializeComponent(); SavedAppications applications = new SavedAppications(); applications.SavedWindows = new List<SavedWindow>(LeechProcesses.Get_Processes()); Applications_ListBox.ItemsSource = applications.SavedWindows; }
private static void SerializationBeta(SavedAppications applicationTest) { string generatedPath = WriteToFile(applicationTest); SavedAppications copy = ReadFromFile(generatedPath); bool test = applicationTest.Equals(copy); if (test) { Console.WriteLine("Basic serialization mastered"); } else { Console.WriteLine("Something went Astray"); } }
private static void OriginalMainMethod() { Console.WriteLine("Beginning application"); SavedAppications applicationTest = new SavedAppications(); int gWid = 150; int gHei = 100; applicationTest.TempateName = "Demacia"; SavedWindow window1 = newSwindow("Notepad.exe", 1, gWid, gHei, 0, 0); SavedWindow window2 = newSwindow("notepad2.exe", 2, gWid, gHei, 12, 50); SavedWindow window3 = newSwindow("firefox.exe", 4, gWid, gHei, 100, 500); applicationTest.Add(window1); applicationTest.Add(window2); applicationTest.Add(window3); string s = JsonConvert.SerializeObject(applicationTest); Console.WriteLine(String.Format("The serialized Object is:\n{0}", s)); //WriteToFile(applicationTest); SavedAppications app2 = JsonConvert.DeserializeObject<SavedAppications>(s); if (applicationTest.Equals(app2)) { Console.WriteLine("\n\nSuccess"); } //SerializationBeta(applicationTest); endProgram(); }
static string WriteToFile(SavedAppications applications) { string pathName = "C:\\IDE\\SavedTemplates"; string pathNameExtended = pathName + "\\" + applications.TempateName + ".txt"; StreamWriter textWriter = new StreamWriter(pathNameExtended, true, Encoding.ASCII); string s = JsonConvert.SerializeObject(applications); textWriter.Write(s); textWriter.Flush(); textWriter.Close(); return pathNameExtended; }