public static List <ArrayProperty> FromDatabaseArray(DatabaseArray input) { var model = new List <ArrayProperty>(); for (var i = 0; i < input.Values.Length; i++) { var value = input.Values[i]; if (value is DatabaseArray array) { model.AddRange(FromDatabaseArray(array)); } else if (value is DatabaseObject obj) { model.Add(new ArrayProperty() { Index = i, Value = new ValueObject() { ValueType = ValueType.Object, ObjectProperties = FromDatabaseObject(obj) } }); } else { model.Add(new ArrayProperty() { Index = i, Value = Create(value) }); } } return(model); }
public static object FromDictionary(object input) { var model = new DatabaseObject(); if (input is Dictionary <string, object> ) { foreach (var kvp in input as Dictionary <string, object> ) { if (kvp.Value is Dictionary <string, object> ) { model.SetProperty(kvp.Key, FromDictionary(kvp.Value as Dictionary <string, object>)); } else if (kvp.Value is object[]) { var array = new DatabaseArray(); foreach (var value in kvp.Value as object[]) { array.Add(FromDictionary(value)); } model.SetProperty(kvp.Key, array); } else if (kvp.Value is List <object> ) { var array = new DatabaseArray(); foreach (var value in kvp.Value as List <object> ) { array.Add(FromDictionary(value)); } model.SetProperty(kvp.Key, array); } else { model.SetProperty(kvp.Key, kvp.Value); } } return(model); } else { return(input); } }
public DatabaseArray GetArray(uint index, DatabaseArray defaultValue) => GetArray(index.ToString(), defaultValue);
/// <summary> Add the given array to the array. </summary> public DatabaseArray Add(DatabaseArray value) => Set((uint)this.Properties.Count, value);
public DatabaseObject Set(string property, DatabaseArray value) => this.SetProperty(property, (object)value);