public void Save() { // Do the saving things IsSaving = true; _fileSystemWatcher.EnableRaisingEvents = false; // Convert layout into persistable objects var persistable = new RootPersistenceNode { Platform = FileSystem.Platform.ToString(), Volumes = FileSystem.Volumes.Select(Save).ToList(), }; // Save JSON to file var settings = new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, CheckAdditionalContent = false, }; var json = JsonConvert.SerializeObject(persistable, Formatting.Indented, settings); using (var fs = OpenFile(Options.FileSystemLayoutFilePath, true)) using (var writer = new StreamWriter(fs) { AutoFlush = true }) writer.Write(json); IsSaving = false; }
private void Load(RootPersistenceNode root) { if (root.Volumes != null) { foreach (var volume in root.Volumes) { Load(volume); } } }