private static TomlObject GetTableRowOrCreateDefault(string key, TomlTable tbl, Type rowType) { return(tbl.TryGetValue(key, out var val) ? val : CreateDefault()); TomlObject CreateDefault() { return(rowType switch { _ => tbl[key] = tbl.CreateEmptyAttachedTable(), }); }
static CombineTablesTests() { X = Toml.Create(); X.Add(XKey, XVal); X.Add(SameKey, XVal); var xs = X.Add(SubTableKey, Toml.Create()); xs.Add(SubTableValueKey, XSubTableVal); Y = Toml.Create(); Y.Add(YKey, YVal); Y.Add(SameKey, YVal); var ys = Y.Add(SubTableKey, X.CreateEmptyAttachedTable()); ys.Add(SubTableValueKey, YSubTableVal); Dx = Toml.Create(); Dx.Add("a", (long)1); Dx.Add("c", (long)3).AddComment("xcc"); Dy = Toml.Create(); Dy.Add("b", (long)2).AddComment("ybc"); Dy.Add("c", (long)4).AddComment("ycc"); }