예제 #1
0
        public void TestTryGetValue()
        {
            IObjectState state = new MutableObjectState
            {
                ObjectId   = "waGiManPutr4Pet1r",
                ClassName  = "Pagi",
                CreatedAt  = new DateTime(),
                ServerData = new Dictionary <string, object>()
                {
                    { "username", "kevin" },
                    { "sessionToken", "se551onT0k3n" }
                }
            };
            AVObject obj = AVObjectExtensions.FromState <AVObject>(state, "Omitted");
            string   res = null;

            obj.TryGetValue <string>("username", out res);
            Assert.AreEqual("kevin", res);

            AVObject resObj = null;

            obj.TryGetValue <AVObject>("username", out resObj);
            Assert.Null(resObj);

            obj.TryGetValue <string>("missingItem", out res);
            Assert.Null(res);
        }
예제 #2
0
        static void OnLiveQueryReceived(object sender, AVLiveQueryEventArgs <AVObject> e)
        {
            AVObject go = e.Payload;

            if (go.TryGetValue("name", out string name))
            {
                Console.WriteLine($"{e.Scope} : {name}");
            }
        }
예제 #3
0
        internal static void RemoveElement <T>(this AVObject source, string key, T elementToRemove)
        {
            List <object> oldValue = null;

            source.TryGetValue(key, out oldValue);
            if (oldValue != null)
            {
                oldValue.Remove(elementToRemove);
                source[key] = oldValue;
            }
        }