private void SaveFileButton_Click(object sender, RoutedEventArgs e) { string serializedFileName = "SerializedObjects.data"; string archivedFileName = "ArchivedObjects.data"; string encryptedFileName = "EncryptedObjects.data"; try { if (list.ListOfObjects.Count > 0) { string serializeResult = SerializeFile(serializedFileName); MessageBox.Show(serializeResult); if (ArchivationSelected()) { ArchiveFile(serializedFileName, archivedFileName); } else if (EncryptionSelected()) { foreach (var classItem in ListOfEncryptionClasses) { if (classItem.Name == "Encryption") { IEncryption encoder = new Encryption(); EncryptionAdapter adapter = new EncryptionAdapter(encoder); adapter.OnSave(serializedFileName, encryptedFileName); } } } else { MessageBox.Show("Select save method"); } } else { MessageBox.Show("Nothing to save"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void LoadFileButton_Click(object sender, RoutedEventArgs e) { string archivedFileName = "ArchivedObjects.data"; string unzipFileName = "UnzipObjects.data"; string encryptedFileName = "EncryptedObjects.data"; string decryptedFileName = "DecryptedObjects.data"; if (ArchivationSelected()) { UnzipFile(archivedFileName, unzipFileName); } else if (EncryptionSelected()) { foreach (var classItem in ListOfEncryptionClasses) { if (classItem.Name == "Encryption") { IEncryption encoder = new Encryption(); EncryptionAdapter adapter = new EncryptionAdapter(encoder); adapter.OnLoad(encryptedFileName, decryptedFileName); } } } else { MessageBox.Show("Select load method"); } list.ListOfObjects = DeserializeFile(unzipFileName, decryptedFileName); if (list.ListOfObjects.Count > 0) { MessageBox.Show("Deserialization was successful!"); } else { MessageBox.Show("File is empty"); } UpdateListBox(); }