bool ICborMapWriter <MapWriterContext> .WriteMapItem(ref CborWriter writer, ref MapWriterContext context) { if (context.enumerator.MoveNext()) { KeyValuePair <CborValue, CborValue> pair = context.enumerator.Current; Write(ref writer, pair.Key); Write(ref writer, pair.Value); return(true); } else { return(false); } }
void ICborConverter <CborObject?> .Write(ref CborWriter writer, CborObject?value, LengthMode lengthMode) { if (value == null) { writer.WriteNull(); return; } MapWriterContext mapWriterContext = new MapWriterContext { obj = value, enumerator = value.GetEnumerator(), lengthMode = lengthMode != LengthMode.Default ? lengthMode : _options.MapLengthMode }; writer.WriteMap(this, ref mapWriterContext); }
int ICborMapWriter <MapWriterContext> .GetMapSize(ref MapWriterContext context) { return(context.lengthMode == LengthMode.IndefiniteLength ? -1 : context.obj.Count); }