public static List <DVAR> Parse(CFGData config) { var dvars = new List <DVAR>(); foreach (var item in config.Lines) { if (item.Value is null) { continue; } if (item.Value.Contains(".") && float.TryParse(item.Value, out _)) { item.DVAR.Type = "float"; } else if (int.TryParse(item.Value, out _)) { item.DVAR.Type = "int"; } else if (bool.TryParse(item.Value, out _)) { item.DVAR.Type = "bool"; } else { item.DVAR.Type = "string"; } dvars.Add(item.DVAR); } return(dvars); }
public static void Update(CFGData config, FileInfo existing_file = null) { if (existing_file is null) { existing_file = new FileInfo(DefaultFileName); } if (!existing_file.Exists) { existing_file.WriteAllText(Serialize(Parse(config))); return; } var existing = Load(existing_file); var _new = Parse(config); var merged = Merge(existing, _new); existing_file.WriteAllText(merged); }
public void Reload() => Data = new CFGData(File.ReadAllText().Trim());