Example #1
0
        public void Save(string filepath)
        {
            var root = new Dictionary<string, MiniYaml>();
            foreach (var field in fields)
            {
                FieldInfo f = this.GetType().GetField(field);
                if (f.GetValue(this) == null) continue;
                root.Add(field, new MiniYaml(FieldSaver.FormatValue(this, f), null));
            }

            var gen = new Dictionary<string, MiniYaml>();
            foreach (var field in fields)
            {
                FieldInfo f = this.GetType().GetField(field);
                if (f.GetValue(this) == null) continue;
                gen.Add(field, new MiniYaml(FieldSaver.FormatValue(this, f), null));
            }
            root.Add("General", new MiniYaml(null, gen));

            root.Add("Terrain",
                new MiniYaml(null, Terrain.ToDictionary(
                    t => "[email protected]{0}".F(t.Value.Type),
                    t => t.Value.Save())));

            root.Add("Templates",
                new MiniYaml(null, Templates.ToDictionary(
                    t => "[email protected]{0}".F(t.Value.Id),
                    t => t.Value.Save())));
            root.WriteToFile(filepath);
        }
Example #2
0
        public void Save()
        {
            Dictionary<string, MiniYaml> root = new Dictionary<string, MiniYaml>();
            foreach (var kv in Sections)
                root.Add(kv.Key, SectionYaml(kv.Value));

            root.WriteToFile(SettingsFile);
        }