public bool Load() { string fp = Path.Combine(Application.persistentDataPath, FILE_NAME); if (File.Exists(fp)) { try { XmlSerializer serializer = new XmlSerializer(typeof(SaveMe)); using (FileStream stream = new FileStream(fp, FileMode.Open)) { _saveMe = serializer.Deserialize(stream) as SaveMe; } return(true); } catch (XmlException e) { Debug.LogError("Error while loading Synonyms! StackTrace:"); Debug.Log(e.StackTrace); _saveMe = new SaveMe(); return(false); } } else { FileStream stream = new FileStream(fp, FileMode.Create); stream.Close(); _saveMe = new SaveMe(); return(false); } }
public static ObservableCollection <Input> Load() { try { System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(SaveMe)); System.IO.StreamReader file = new System.IO.StreamReader(curretPath); SaveMe overview = (SaveMe)reader.Deserialize(file); file.Close(); return(overview.Inputs); } catch { Save(); return(new SaveMe().Inputs); } }
public static void Save() { try { var s = new SaveMe() { Inputs = MainWindow.vm.Inputs }; var writer = new System.Xml.Serialization.XmlSerializer(typeof(SaveMe)); var wfile = new System.IO.StreamWriter(curretPath); writer.Serialize(wfile, s); wfile.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SetVideoSavingMode(SaveMe mode) { switch (mode) { case SaveMe.Always: { _saveFailedOnly = false; break; } case SaveMe.OnlyWhenFailed: { _saveFailedOnly = true; break; } default: throw new ArgumentException("Saving mode is not valid!"); } }