internal static TomlTable CreateFromComplexObject <T>(ITomlRoot root, T obj, TableTypes tableType) { if (root == null) { throw new ArgumentNullException(nameof(root)); } if (obj == null) { throw new ArgumentNullException(nameof(obj)); } TomlTable tt = new TomlTable(root, tableType); var props = root.Settings.GetSerializationProperties(obj.GetType()); var allObjects = new List <Tuple <string, TomlObject> >(); foreach (var p in props) { object val = p.GetValue(obj, null); if (val != null) { TomlObject to = TomlObject.CreateFrom(root, val, p); AddComments(to, p); tt.AddRow(new TomlKey(p.Name), to); } } return(tt); }
public static TomlFloat AddValue(this TomlTable table, string key, double value) { var f = table.CreateAttachedValue(value); table.AddRow(new TomlKey(key), f); return(f); }
public static TomlInt AddValue(this TomlTable table, string key, long value) { var i = table.CreateAttachedValue(value); table.AddRow(new TomlKey(key), i); return(i); }
public static TomlString AddValue(this TomlTable table, string key, string value) { var s = table.CreateAttachedValue(value); table.AddRow(new TomlKey(key), table.CreateAttachedValue(value)); return(s); }
public static TomlDateTime AddValue(this TomlTable table, string key, DateTimeOffset dateTime) { var dt = table.CreateAttachedValue(dateTime); table.AddRow(new TomlKey(key), dt); return(dt); }
public static TomlBool AddValue(this TomlTable table, string key, bool value) { var b = table.CreateAttachedValue(value); table.AddRow(new TomlKey(key), b); return(b); }
public static TomlTimeSpan AddValue(this TomlTable table, string key, TimeSpan timeSpan) { var ts = table.CreateAttachedValue(timeSpan); table.AddRow(new TomlKey(key), ts); return(ts); }
#pragma warning restore SA1313 // Parameter names must begin with lower-case letter // Internal private static T AddTomlObjectInternal <T>(TomlTable table, string key, T o) where T : TomlObject { Assert(o.Root == table.Root); table.AddRow(new TomlKey(key), o); return(o); }
internal static TomlTable CreateFromComplexObject <T>(ITomlRoot root, T obj, TableTypes tableType) { if (root == null) { throw new ArgumentNullException(nameof(root)); } if (obj == null) { throw new ArgumentNullException(nameof(obj)); } TomlTable tt = new TomlTable(root, tableType); var members = root.Settings.GetSerializationMembers(obj.GetType()); var allObjects = new List <Tuple <string, TomlObject> >(); foreach (var m in members) { object val = m.GetValue(obj); if (val != null) { TomlObject to = TomlObject.CreateFrom(root, val); to.AddComments(root.Settings.GetComments(obj.GetType(), m.Member)); tt.AddRow(m.Key, to); } } return(tt); }
protected virtual TomlTable CloneForInternal(TomlTable cloneTarget) { foreach (var r in this.rows) { cloneTarget.AddRow(r.Key, r.Value.CloneFor(cloneTarget.Root)); } return(CopyComments(cloneTarget, this)); }
public static TomlTableArray AddTableArray(this TomlTable table, string key, TomlTableArray array) { if (array.Root != table.Root) { throw new InvalidOperationException("Cannot add TOML table array to table because it belongs to a different graph root."); } table.AddRow(new TomlKey(key), array); return(array); }
internal TomlTable CloneTableFor(ITomlRoot root) { var tbl = new TomlTable(root, this.TableType); foreach (var r in this.rows) { tbl.AddRow(r.Key, r.Value.CloneFor(root)); } return(tbl); }
internal TomlTable TableWithRoot(ITomlRoot root) { root.CheckNotNull(nameof(root)); var table = new TomlTable(root, this.TableType); foreach (var r in this.rows) { table.AddRow(r.Key, r.Value.WithRoot(root)); } return(table); }
internal static TomlTable CreateFromDictionary(ITomlRoot root, IDictionary dict, TableTypes tableType) { if (root == null) { throw new ArgumentNullException(nameof(root)); } if (dict == null) { throw new ArgumentNullException(nameof(dict)); } var tomlTable = new TomlTable(root, tableType); foreach (DictionaryEntry r in dict) { var obj = TomlObject.CreateFrom(root, r.Value); tomlTable.AddRow(new TomlKey((string)r.Key), obj); } return tomlTable; }
public static TomlTable CreateAttachedTable( this TomlObject rootSource, IEnumerable <KeyValuePair <string, TomlObject> > rows, TomlTable.TableTypes type = TomlTable.TableTypes.Default) { var tbl = new TomlTable(rootSource.Root, type); foreach (var kvp in rows) { if (kvp.Value.Root != rootSource.Root) { throw new InvalidOperationException( "Cannot create table with rows belonging to a different TOML object graph root."); } tbl.AddRow(new TomlKey(kvp.Key), kvp.Value); } return(tbl); }
internal static TomlTable CreateFromDictionary <T>(ITomlRoot root, IDictionary <string, T> dict, TableTypes tableType) { if (root == null) { throw new ArgumentNullException(nameof(root)); } if (dict == null) { throw new ArgumentNullException(nameof(dict)); } var tomlTable = new TomlTable(root, tableType); foreach (var kvp in dict) { var obj = TomlObject.CreateFrom(root, kvp.Value); tomlTable.AddRow(new TomlKey(kvp.Key), obj); } return(tomlTable); }
public static TomlArray AddArray(this TomlTable table, string key, TomlArray a) { table.AddRow(new TomlKey(key), a); return(a); }
public static TomlTable AddTable(this TomlTable table, string key, TomlTable t) { table.AddRow(new TomlKey(key), t); return(t); }