Esempio n. 1
0
        public IDictionary <string, object> EncodeParseObject(AVObject value, bool isPointer)
        {
            if (isPointer)
            {
                return(EncodeParseObject(value));
            }

            var operations    = value.GetCurrentOperations();
            var operationJSON = AVObject.ToJSONObjectForSaving(operations);
            var objectJSON    = value.ToDictionary(kvp => kvp.Key, kvp => EncodeProperty(kvp.Value));

            foreach (var kvp in operationJSON)
            {
                objectJSON[kvp.Key] = kvp.Value;
            }
            if (value.CreatedAt.HasValue)
            {
                objectJSON["createdAt"] = value.CreatedAt.Value.ToString(DateFormatStrings.First(),
                                                                         CultureInfo.InvariantCulture);
            }
            if (value.UpdatedAt.HasValue)
            {
                objectJSON["updatedAt"] = value.UpdatedAt.Value.ToString(DateFormatStrings.First(),
                                                                         CultureInfo.InvariantCulture);
            }
            if (!string.IsNullOrEmpty(value.ObjectId))
            {
                objectJSON["objectId"] = value.ObjectId;
            }
            objectJSON["className"] = value.ClassName;
            objectJSON["__type"]    = "Object";
            return(objectJSON);
        }
Esempio n. 2
0
        public void TestRevert()
        {
            AVObject obj = AVObject.Create("Corgi");

            obj["gogo"] = true;

            Assert.True(obj.IsDirty);
            Assert.AreEqual(1, obj.GetCurrentOperations().Count);
            Assert.True(obj.ContainsKey("gogo"));

            obj.Revert();

            Assert.True(obj.IsDirty);
            Assert.AreEqual(0, obj.GetCurrentOperations().Count);
            Assert.False(obj.ContainsKey("gogo"));
        }