示例#1
0
        public static async Task <object> RPC(string name, object parameters = null)
        {
            string path         = $"call/{name}";
            object encodeParams = ParseEncoder.Encode(parameters);
            Dictionary <string, object> response = await ParseClient.HttpClient.Post <Dictionary <string, object> >(path,
                                                                                                                    data : encodeParams);

            return(ParseDecoder.Decode(response["result"]));
        }
示例#2
0
        public void TestParseDate()
        {
            DateTime dateTime = (DateTime)ParseDecoder.Instance.Decode(ParseDecoder.ParseDate("1990-08-30T12:03:59.000Z"));

            Assert.AreEqual(1990, dateTime.Year);
            Assert.AreEqual(8, dateTime.Month);
            Assert.AreEqual(30, dateTime.Day);
            Assert.AreEqual(12, dateTime.Hour);
            Assert.AreEqual(3, dateTime.Minute);
            Assert.AreEqual(59, dateTime.Second);
            Assert.AreEqual(0, dateTime.Millisecond);
        }
示例#3
0
        public static ParseObjectData Decode(IDictionary dict)
        {
            if (dict == null)
            {
                return(null);
            }
            ParseObjectData objectData = new ParseObjectData();

            foreach (DictionaryEntry kv in dict)
            {
                string key   = kv.Key.ToString();
                object value = kv.Value;
                if (key == "className")
                {
                    objectData.ClassName = value.ToString();
                }
                else if (key == "objectId")
                {
                    objectData.ObjectId = value.ToString();
                }
                else if (key == "createdAt" && DateTime.TryParse(value.ToString(), out DateTime createdAt))
                {
                    objectData.CreatedAt = createdAt.ToLocalTime();
                }
                else if (key == "updatedAt" && DateTime.TryParse(value.ToString(), out DateTime updatedAt))
                {
                    objectData.UpdatedAt = updatedAt.ToLocalTime();
                }
                else
                {
                    if (key == "ACL" &&
                        value is Dictionary <string, object> dic)
                    {
                        objectData.CustomPropertyDict[key] = ParseDecoder.DecodeACL(dic);
                    }
                    else
                    {
                        objectData.CustomPropertyDict[key] = ParseDecoder.Decode(value);
                    }
                }
            }
            return(objectData);
        }