public void read(string _path) { if (_path != null) path = _path; IniSection actSect = null; actSect = new IniSection(""); sections.Add("", actSect); if (!File.Exists(path)) return; string[] lines = File.ReadAllLines(path, Encoding.UTF8); foreach (string line in lines) { string tl = line.Trim(); if (tl.StartsWith("#")) continue; // comment if (tl.StartsWith("[") && tl.EndsWith("]")) { string secname = tl.Substring(1, tl.Length - 2); actSect = sections[secname]; if (actSect == null) { actSect = new IniSection(secname); sections.Add(secname, actSect); } continue; } int p = tl.IndexOf('='); if (p < 0) continue; actSect.addLine(line); } }
public void flatten() { IniSection flat = sections[""]; LinkedList <IniSection> dellist = new LinkedList <IniSection>(); foreach (IniSection s in sections.Values) { if (s.name == "") { continue; } foreach (string line in s.entries.Values) { flat.addLine(line); } dellist.AddLast(s); } foreach (IniSection s in dellist) { sections.Remove(s.name); } }
public void merge(IniSection s) { foreach (String name in s.entries.Keys) { if (name == "extrusion_multiplier" || name == "filament_diameter" || name=="first_layer_temperature" || name =="temperature") { if (entries.ContainsKey(name)) { string full = s.entries[name]; int p = full.IndexOf('='); if (p >= 0) full = full.Substring(p + 1).Trim(); entries[name] += "," + full; } else { entries.Add(name, s.entries[name]); } } } }
public void merge(IniSection s) { foreach (String name in s.entries.Keys) { if (name == "extrusion_multiplier" || name == "filament_diameter" || name == "first_layer_temperature" || name == "temperature") { if (entries.ContainsKey(name)) { string full = s.entries[name]; int p = full.IndexOf('='); if (p >= 0) { full = full.Substring(p + 1).Trim(); } entries[name] += "," + full; } else { entries.Add(name, s.entries[name]); } } } }