Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 public DatabaseObject Set(string property, DatabaseArray value) => this.SetProperty(property, (object)value);
Exemplo n.º 4
0
 /// <summary> Add the given array to the array. </summary>
 public DatabaseArray Add(DatabaseArray value) => Set((uint)this.Properties.Count, value);
Exemplo n.º 5
0
 public DatabaseArray GetArray(uint index, DatabaseArray defaultValue) => GetArray(index.ToString(), defaultValue);