Example #1
0
        public void Patch()
        {
            var po = ObjectDiff.ToJObject(new
            {
                a = 1,
                b = 2,
                c = new
                {
                    d = 3
                }
            });

            var co = ObjectDiff.ToJObject(new
            {
                a = 1,
                b = 2,
                c = new
                {
                    d = 3
                }
            });

            co["a"] = 2;
            (co["c"] as JObject).Add("e", 4);
            ((JObject)co).Remove("b");

            var diff = new ObjectDiff(po, co);

            var patch = diff.Patch(po) as JObject;

            Assert.AreEqual(((JValue)co["a"]).Value, ((JValue)patch["a"]).Value);
            Assert.IsNull(patch.Property("b"));
            Assert.AreEqual(4, ((JValue)((JObject)patch["c"])["e"]).Value);
        }
Example #2
0
        internal void UpdateState(ObjectDiff diff)
        {
            lock (this)
            {
                _state.Add(diff.Id, diff);
                _fullState = diff.Patch(_fullState);

                _client.UIRPC.FireStateUpdated(diff);
            }
        }