internal DatabaseObject(string table, string key, string version, List <ObjectProperty> properties) { this.Table = table; this.Key = key; this.Version = version; this.Properties = new Dictionary <string, object>(); this.ExistsInDatabase = true; if (properties != null) { this.Properties = (DatabaseObjectExtensions.FromDictionary(DatabaseObjectExtensions.ToDictionary(properties)) as DatabaseObject).Properties; } }
internal static List <ValueObject> MakeRange(object[] indexPath, object tail) { var result = new object[((indexPath == null) ? 0 : indexPath.Length) + ((tail == null) ? 0 : 1)]; if (indexPath != null) { Array.Copy(indexPath, result, indexPath.Length); } if (tail != null) { result[result.Length - 1] = tail; } return(result.Select(value => DatabaseObjectExtensions.Create(value)).ToList()); }
public void CreateObject(string table, string key, DatabaseObject obj) { File.WriteAllText(Path.Combine(this.StorageLocation, table, key + ".tson"), TsonConvert.SerializeObject(DatabaseObjectExtensions.ToDictionary(obj.Properties), Formatting.Indented)); }
/// <summary> /// This method allows you to load a Database Object (properties only) from a TSON string. /// </summary> /// <param name="input"> The TSON string. </param> /// <returns> A database object containing the properties of the deserialized TSON. </returns> public static DatabaseObject LoadFromString(string input) => DatabaseObjectExtensions.FromDictionary(TsonConvert.DeserializeObject(input)) as DatabaseObject;