/// <summary> /// Serialized a map. The default implementation first ensure that the value is indeed a map and then uses /// GetMapSize() and GetMapElements() to access the contents of the map. /// </summary> /// <param name="schema">The MapSchema for serialization</param> /// <param name="value">The value to be serialized</param> /// <param name="encoder">The encoder for serialization</param> protected void WriteMap(WriteItem itemWriter, object value, Encoder encoder) { _mapAccess.EnsureMapObject(value); encoder.WriteMapStart(); encoder.SetItemCount(_mapAccess.GetMapSize(value)); _mapAccess.WriteMapValues(value, itemWriter, encoder); encoder.WriteMapEnd(); }
private void WriteArray(WriteItem itemWriter, object array, Encoder encoder) { _arrayAccess.EnsureArrayObject(array); long l = _arrayAccess.GetArrayLength(array); encoder.WriteArrayStart(); encoder.SetItemCount(l); _arrayAccess.WriteArrayValues(array, itemWriter, encoder); encoder.WriteArrayEnd(); }