Exemplo n.º 1
0
        public override string Parse(RedisReader reader)
        {
            if (IsEmpty)
            {
                RedisMessage type = reader.ReadType();
                if ((int)type == -1)
                {
                    return(string.Empty);
                }
                else if (type == RedisMessage.Error)
                {
                    throw new RedisException(reader.ReadStatus(false));
                }

                throw new RedisProtocolException($"Unexpected type: {type}");
            }
            else if (IsNullable)
            {
                RedisMessage type = reader.ReadType();
                if (type == RedisMessage.Status)
                {
                    return(reader.ReadStatus(false));
                }

                object[] result = reader.ReadMultiBulk(false);
                if (result != null)
                {
                    throw new RedisProtocolException($"Expecting null MULTI BULK response. Received: {result.ToString()}");
                }

                return(null);
            }
            else
            {
                return(reader.ReadStatus());
            }
        }
Exemplo n.º 2
0
            public override string Parse(RedisReader reader)
            {
                RedisMessage type = reader.ReadType();

                if ((int)type == -1)
                {
                    return(String.Empty);
                }
                else if (type == RedisMessage.Error)
                {
                    throw new RedisException(reader.ReadStatus(false));
                }

                throw new RedisProtocolException("Unexpected type: " + type);
            }
Exemplo n.º 3
0
        private static string ParseStream(Stream stream)
        {
            RedisMessage type = RedisReader.ReadType(stream);

            if (type == RedisMessage.Status)
            {
                return(RedisReader.ReadStatus(stream, false));
            }

            object[] result = RedisReader.ReadMultiBulk(stream, false);
            if (result != null)
            {
                throw new RedisProtocolException("Expecting null MULTI BULK response. Received: " + result.ToString());
            }
            return(null);
        }
Exemplo n.º 4
0
            public override string Parse(RedisReader reader)
            {
                RedisMessage type = reader.ReadType();

                if (type == RedisMessage.Status)
                {
                    return(reader.ReadStatus(false));
                }

                object[] result = reader.ReadMultiBulk(false);
                if (result != null)
                {
                    throw new RedisProtocolException("Expecting null MULTI BULK response. Received: " + result.ToString());
                }

                return(null);
            }
Exemplo n.º 5
0
            public override string Parse(RedisReader reader)
            {
                RedisMessage type = reader.ReadType();

                if (type == RedisMessage.Status)
                {
                    return(reader.ReadStatus(false));
                }

                object[] result = reader.ReadMultiBulk(false);
                if (result != null && result.Length > 0)
                {
                    throw new RedisProtocolException("Expecting null MULTI BULK response for command '" + this.Command + "'. Received: " + String.Join(", ", result));
                }

                return(null);
            }
Exemplo n.º 6
0
 public override string Parse(RedisReader reader)
 {
     return(reader.ReadStatus());
 }