コード例 #1
0
 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);
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 int ICborMapWriter <MapWriterContext> .GetMapSize(ref MapWriterContext context)
 {
     return(context.lengthMode == LengthMode.IndefiniteLength ? -1 : context.obj.Count);
 }