private void parse(StreamReader sr) { String section = null; SectMap sechash = new SectMap(); confhash.Clear(); String line; while (sr.Peek() >= 0) { line = sr.ReadLine().Trim(); if (line.Length == 0) continue; Char c = line[0]; if (c == '#' || c == ';') continue; if (c == '[') { line = line.Substring(1, line.IndexOf(']')-1).Trim(); if (section != null) { confhash[section] = sechash; sechash = new SectMap(); } section = line; } else { String[] key_value = line.Split("=".ToCharArray(), 2); sechash[key_value[0].Trim()] = key_value[1].Trim(); } } if (section != null) confhash[section] = sechash; }
public void TestSectorizationModel() { SectMap map1 = new SectMap() { { "001", 1 }, { "002", 2 }, { "003", 3 }, }; SectMap map2 = new SectMap() { { "011", 11 }, { "012", 12 }, { "013", 13 }, { "014", 15 }, }; SectorizationPersistence.Set("map1", map1); SectorizationPersistence.Set("map2", map2); SectorizationPersistence.Set("map3", map2); SectorizationPersistence.Get("map3", (date, map) => { }); SectorizationPersistence.Sanitize(new List <string>() { "map1", "map3" }); }
public void MergeSectorization(SectMap map) { foreach (var item in map) { sectorization[item.Key] = item.Value; } SectorizationPersistence.Set(Cfg.Id, sectorization); LastChange = DateTime.Now; }
public static string MapToString(SectMap map) { var mapstr = string.Empty; foreach (var entry in map) { mapstr += $"{entry.Key}:{entry.Value},"; } return(mapstr); }
public void put(String section, String key, String val) { lock (conflock) { SectMap sechash; if (!confhash.TryGetValue(section, out sechash)) { sechash = new SectMap(); confhash[section] = sechash; } sechash[key] = val; } }
public SectMap Map(SectMap map) { SectMap mapped = new SectMap(); foreach (var item in map) { var newSect = Int32.Parse(item.Key); var newPosi = item.Value; mapped.Add(SectorsMap.ContainsKey(newSect) ? SectorsMap[newSect].ToString() : newSect.ToString(), PositionsMap.ContainsKey(newPosi) ? PositionsMap[newPosi] : newPosi); } return(mapped); }
private void parse(StreamReader sr) { String section = null; SectMap sechash = new SectMap(); confhash.Clear(); String line; while (sr.Peek() >= 0) { line = sr.ReadLine().Trim(); if (line.Length == 0) { continue; } Char c = line[0]; if (c == '#' || c == ';') { continue; } if (c == '[') { line = line.Substring(1, line.IndexOf(']') - 1).Trim(); if (section != null) { confhash[section] = sechash; sechash = new SectMap(); } section = line; } else { String[] key_value = line.Split("=".ToCharArray(), 2); sechash[key_value[0].Trim()] = key_value[1].Trim(); } } if (section != null) { confhash[section] = sechash; } }
public static void Set(string id, SectMap map) { var item = PersistenceItems.Where(i => i.Id == id).FirstOrDefault(); if (item != null) { item.Date = DateTime.Now; item.Map = map; } else { PersistenceItems.Add(new PersistenceItem() { Date = DateTime.Now, Id = id, Map = map }); } WriteData(); }