예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 public void Reload() => Data = new CFGData(File.ReadAllText().Trim());