public void DeserializeAndApplyChangeValue(Change change, DeserializingContext context)
        {
            var property = change.Key;

            if (_values.TryGetValue(property, out var value))
            {
                switch (change.Type)
                {
                case ChangeType.Add:
                    _manager.DeserializeIgnoredValue(context, change, "Unsync on add");
                    break;

                case ChangeType.Remove:
                    _manager.DeserializeAndApplyRemove(value, change);
                    _values.Remove(property);
                    _propertyChangedHandler?.Invoke(Proxy, new PropertyChangedEventArgs(property));
                    break;

                case ChangeType.Replace:
                    _values[property] = _manager.DeserializeAndApplyReplace(this, property, value, _typeConfig.Members[property].TypeConfiguration, change, context);
                    _propertyChangedHandler?.Invoke(Proxy, new PropertyChangedEventArgs(property));
                    break;
                }
            }
            else
            {
                if (_typeConfig.Members.TryGetValue(property, out var memConfig))
                {
                    if (change.Type == ChangeType.Add)
                    {
                        _values.Add(property, _manager.DeserializeAndApplyAdd(this, property, memConfig.TypeConfiguration, change, context));
                        _propertyChangedHandler?.Invoke(Proxy, new PropertyChangedEventArgs(property));
                    }
                    else
                    {
                        if (change.Type == ChangeType.Replace)
                        {
                            _manager.DeserializeIgnoredValue(context, change, "Unsync on replace");
                        }
                    }
                }
                else
                {
                    if (change.Type != ChangeType.Remove)
                    {
                        _manager.DeserializeIgnoredValue(context, change, "Unknown property");
                    }
                }
            }
        }
Example #2
0
        public void DeserializeAndApplyChangeValue(Change change, DeserializingContext context)
        {
            var property = change.Key;

            if (_inner.TryGetValue(property, out var oldValue))
            {
                switch (change.Type)
                {
                case ChangeType.Add:
                    _manager.DeserializeIgnoredValue(context, change, "Unsync on dict add");
                    break;

                case ChangeType.Remove:
                    _manager.DeserializeAndApplyRemove(oldValue, change);
                    InternalRemove(property, oldValue);
                    break;

                case ChangeType.Replace:
                    InternalReplace(property, oldValue, _manager.DeserializeAndApplyReplace(this, property, oldValue, _typeConfig.ValueType, change, context));
                    break;
                }
            }
            else
            {
                if (change.Type == ChangeType.Add)
                {
                    InternalAdd(property, _manager.DeserializeAndApplyAdd(this, property, _typeConfig.ValueType, change, context));
                }
                else
                {
                    if (change.Type == ChangeType.Replace)
                    {
                        _manager.DeserializeIgnoredValue(context, change, "Unsync on dict replace");
                    }
                }
            }
        }