Esempio n. 1
0
        /// <summary>
        /// Seek past the value for the previously read key.
        /// </summary>
        public static void SkipKey(Stream stream, Key key)
        {
            switch (key.WireType)
            {
            case Wire.Fixed32:
                stream.Seek(4, SeekOrigin.Current);
                return;

            case Wire.Fixed64:
                stream.Seek(8, SeekOrigin.Current);
                return;

            case Wire.LengthDelimited:
                stream.Seek(ProtocolParser.ReadUInt32(stream), SeekOrigin.Current);
                return;

            case Wire.Varint:
                ProtocolParser.ReadSkipVarInt(stream);
                return;

            case Wire.Start:
                ProtocolParser.ReadSkipGroup(stream, key);
                return;

            default:
                throw new NotImplementedException("Unknown wire type: " + key.WireType);
            }
        }