internal ParsePushNotificationEventArgs(IDictionary <string, object> payload) { Payload = payload; #if !IOS StringPayload = JsonProcessor.Encode(payload); #endif }
public void TestGeoPointCultureInvariantParsing() { CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture; foreach (CultureInfo c in CultureInfo.GetCultures(CultureTypes.AllCultures)) { Thread.CurrentThread.CurrentCulture = c; ParseGeoPoint point = new ParseGeoPoint(1.234, 1.234); string serialized = JsonProcessor.Encode(new Dictionary <string, object> { { "point", NoObjectsEncoder.Instance.Encode(point) } }); IDictionary <string, object> deserialized = ParseDecoder.Instance.Decode(JsonProcessor.Parse(serialized)) as IDictionary <string, object>; ParseGeoPoint pointAgain = (ParseGeoPoint)deserialized["point"]; Assert.AreEqual(1.234, pointAgain.Latitude); Assert.AreEqual(1.234, pointAgain.Longitude); } }
public void TestEncodeJson() { Dictionary <string, object> dict = new Dictionary <string, object>(); string encoded = JsonProcessor.Encode(dict); Assert.AreEqual("{}", encoded); List <object> list = new List <object>(); encoded = JsonProcessor.Encode(list); Assert.AreEqual("[]", encoded); Dictionary <string, object> dictChild = new Dictionary <string, object>(); list.Add(dictChild); encoded = JsonProcessor.Encode(list); Assert.AreEqual("[{}]", encoded); list.Add("1234 a\t\r\n"); list.Add(1234); list.Add(12.34); list.Add(1.23456789123456789); encoded = JsonProcessor.Encode(list); Assert.AreEqual("[{},\"1234 a\\t\\r\\n\",1234,12.34,1.23456789123457]", encoded); dict["arr"] = new List <object>(); encoded = JsonProcessor.Encode(dict); Assert.AreEqual("{\"arr\":[]}", encoded); dict["\u1234"] = "\u1234"; encoded = JsonProcessor.Encode(dict); Assert.AreEqual("{\"arr\":[],\"\u1234\":\"\u1234\"}", encoded); encoded = JsonProcessor.Encode(new List <object> { true, false, null }); Assert.AreEqual("[true,false,null]", encoded); }
public Task SetAsync(ParseInstallation installation, CancellationToken cancellationToken) { return(taskQueue.Enqueue(toAwait => { return toAwait.ContinueWith(_ => { Task saveTask = storageController.LoadAsync().OnSuccess(storage => { if (installation == null) { return storage.Result.RemoveAsync(ParseInstallationKey); } else { var data = installationCoder.Encode(installation); return storage.Result.AddAsync(ParseInstallationKey, JsonProcessor.Encode(data)); } }).Unwrap(); CurrentInstallation = installation; return saveTask; }).Unwrap(); }, cancellationToken)); }