示例#1
0
        public ValuePacket ReadValue(bool includeVersion)
        {
            var status = m_parser.ReadStatus();

            if (status == ResponseStatus.Value)
            {
                var key     = m_parser.ReadKey();
                var flags   = m_parser.ReadFlags();
                var length  = m_parser.ReadLength();
                var version = includeVersion ? m_parser.ReadVersion() : 0;
                var value   = m_parser.ReadValue(length);

                return(new ValuePacket()
                {
                    Flags = flags,
                    Key = key,
                    Value = value,
                    Version = version
                });
            }

            if (status != ResponseStatus.NoError && status != ResponseStatus.KeyNotFound)
            {
                throw new InvalidOperationException();
            }

            return(null);
        }