private void LoadKnownGroupsToCache() { KnownGroupsList res = LoadKnownGroupsFile(); lock (_sync) { _cache = res; } }
private void btnApply_Click(object sender, EventArgs e) { this.Groups = new KnownGroupsList(); foreach (var item in lvGroups.Items) { GLItem i = (GLItem)item; KnownGroup kg = (KnownGroup)i.Tag; this.Groups.List.Add(kg); } }
private void SaveKnownGroupsToFile(KnownGroupsList list) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; FileStream fs = new FileStream(KNOWN_GROUP_FILE, FileMode.OpenOrCreate); XmlWriter writer = XmlWriter.Create(fs, settings); XmlSerializer ser = new XmlSerializer(typeof(KnownGroupsList)); ser.Serialize(writer, _cache); writer.Flush(); fs.Close(); }
private void btnEditKnownGroups_Click(object sender, EventArgs e) { KnownGroupsList res = LoadKnownGroupsFile(); KnownGroupsForm f = new KnownGroupsForm(); f.Groups = res; DialogResult dr = f.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { res = f.Groups; lock (_sync) { _cache = res; } SaveKnownGroupsToFile(f.Groups); } }
private KnownGroupsList LoadKnownGroupsFile() { FileStream fs = null; XmlTextReader reader = null; try { fs = new FileStream(KNOWN_GROUP_FILE, FileMode.Open); reader = new XmlTextReader(fs); XmlSerializer ser = new XmlSerializer(typeof(KnownGroupsList)); KnownGroupsList res = (KnownGroupsList)ser.Deserialize(reader); reader.Close(); return(res); } catch { return(null); } }