public void Write(ExtendedBinaryWriter writer, IFieldSerializer keySerializer,
                              IFieldSerializer valueSerializer)
            {
                writer.Write((byte)_action);

                switch (_action)
                {
                case NotifyCollectionChangedAction.Add:
                    keySerializer.Serialize(_items[0].Key, writer);
                    valueSerializer.Serialize(_items[0].Value, writer);
                    break;

                case NotifyCollectionChangedAction.Replace:
                    keySerializer.Serialize(_items[0].Key, writer);
                    valueSerializer.Serialize(_items[0].Value, writer);
                    break;

                case NotifyCollectionChangedAction.Remove:
                    keySerializer.Serialize(_items[0].Key, writer);
                    break;

                case NotifyCollectionChangedAction.Reset:
                {
                    writer.Write7BitEncodedInt(_items.Count);
                    foreach (KeyValuePair <TKey, TValue> item in _items)
                    {
                        keySerializer.Serialize(item.Key, writer);
                        valueSerializer.Serialize(item.Value, writer);
                    }

                    break;
                }
                }
            }
Example #2
0
        protected virtual void SerializeField(Field field, JsonTextWriter writer)
        {
            IFieldSerializer fieldSerializer = this.GetFieldSerializer(field);

            fieldSerializer.EnableRenderedValues = Context.PageMode.IsExperienceEditorEditing;
            fieldSerializer.Serialize(field, writer);
        }
Example #3
0
 internal void Serialize(ExtendedBinaryWriter writer)
 {
     _fieldSerializer.Serialize(Value, writer);
 }