public void Save() { FunctionsRoot root = new FunctionsRoot(); root.Functions = _allFunctions; string dicretory = new FileInfo(_saveFile).DirectoryName; if (!Directory.Exists(dicretory)) { Directory.CreateDirectory(dicretory); } using (StreamWriter writer = new StreamWriter(_saveFile)) { string sData = JsonConvert.SerializeObject(root, Formatting.Indented); writer.Write(sData); } }
public void Load() { if (!File.Exists(_saveFile)) { return; } using (StreamReader writer = new StreamReader(_saveFile)) { FunctionsRoot data = JsonConvert.DeserializeObject <FunctionsRoot>(writer.ReadToEnd()); _allFunctions = data.Functions; foreach (Function currentFunction in data.Functions) { if (_allowedTypes.Contains(currentFunction.Type)) { _availablefunctions.Add(currentFunction); } } } }