// parse json private static void Fill(string json) { Group data = JsonConvert.DeserializeObject <Group>(json); Dictionary <int, Fate> fates = new Dictionary <int, Fate>(); foreach (var area in data.Areas) { foreach (var fate in area.Value.Fates) { try { fate.Value.Area = area.Value; fates.Add(fate.Key, fate.Value); } catch (NullReferenceException /*nex*/) { Mesg.E("e-null-data", fate.Key); } catch (Exception ex) { Mesg.Ex(ex, "l-data-error"); } } } Roulettes = data.Roulettes; Instances = data.Instances; Areas = data.Areas; Fates = fates; }
private void SaveSettings() { if (!_isInitSetting) { return; } txtOverayLocation.Text = $"{Settings.OverlayLocation.X},{Settings.OverlayLocation.Y}"; try { using (var fs = new FileStream(Settings.Path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) using (var xw = new XmlTextWriter(fs, Encoding.UTF8) { Formatting = Formatting.Indented, Indentation = 1, IndentChar = '\t' }) { xw.WriteStartDocument(true); xw.WriteStartElement("Config"); // <Config> xw.WriteStartElement("SettingsSerializer"); // <Config><SettingsSerializer> _srset.ExportToXml(xw); // Fill the SettingsSerializer XML xw.WriteEndElement(); // </SettingsSerializer> xw.WriteEndElement(); // </Config> xw.WriteEndDocument(); // Tie up loose ends (shouldn't be any) xw.Flush(); // Flush the file buffer to disk xw.Close(); } } catch (Exception ex) { Mesg.Ex(ex, "Exception: save setting failed"); } }