예제 #1
0
        ArraySegment <Byte> _Parse()
        {
            ArraySegment <Byte> current;

            if (FormatType.IsArray())
            {
                uint count;
                current = GetItemCount(out count);
                //Children = new MsgPackValue[count];
                for (var i = 0; i < count; ++i)
                {
                    var child = new MessagePackParser(current);
                    current = child._Parse();
                }
            }
            else if (FormatType.IsMap())
            {
                uint count;
                current = GetItemCount(out count);
                //Children = new MsgPackValue[count * 2];
                var childCount = count * 2;
                for (var i = 0; i < childCount; ++i)
                {
                    var child = new MessagePackParser(current);
                    current = child._Parse();
                }
            }
            else
            {
                var body   = GetBody();
                var header = body.Offset - Bytes.Offset;
                current = Bytes.Advance(header + body.Count);
            }
            var size   = current.Offset - Bytes.Offset;
            var result = Bytes.Advance(size);

            Bytes = Bytes.Take(size);
            return(result);
        }
예제 #2
0
 public override string ToString()
 {
     if (FormatType.IsArray())
     {
         return("array(" + Count + ")");
     }
     else if (FormatType.IsMap())
     {
         return("map(" + Count + ")");
     }
     else if (FormatType.IsExt())
     {
         return("ext");
     }
     else if (FormatType.IsBinary())
     {
         return("binary");
     }
     else
     {
         return(GetValue().ToString());
     }
 }