예제 #1
0
            internal override T[] Parse(RedisExecutor executor)
            {
                executor.AssertType(RedisReplyType.MultiBulk);
                long count = executor.ReadInteger(false);

                return(Read(count / this._parseItemCount, executor).ToArray());
            }
예제 #2
0
 protected virtual IEnumerable <T> Read(long count, RedisExecutor stream)
 {
     for (int i = 0; i < count; i++)
     {
         yield return(_command.Parse(stream));
     }
 }
예제 #3
0
            internal override Result Parse(RedisExecutor executor)
            {
                executor.AssertType(RedisReplyType.MultiBulk);
                var count = executor.ReadInteger(false);

                if (count != this._tranCommands.Count)
                {
                    throw new RedisProtocolException(String.Format("预期 {0} 事务返回项,实际只有 {1} 个返回项。", this._tranCommands.Count, count));
                }
                var            node   = this._tranCommands.First;
                Queue <object> values = new Queue <object>((int)count);

                try
                {
                    do
                    {
                        values.Enqueue(node.Value.ObjectParse(executor));
                        node = node.Next;
                    } while(node != null);
                }
                catch (Exception)
                {
                    this._tranCommands.Clear();
                    throw;
                }

                this._tranCommands.Each(command => command.RunCallback(values.Dequeue()));
                this._tranCommands.Clear();
                return(Result.Successfully);
            }
예제 #4
0
        internal override RedisType Parse(RedisExecutor executor)
        {
            executor.AssertType(RedisReplyType.Status);
            var type_s = executor.ReadLine();

            return((RedisType)Enum.Parse(REDIS_TYPE, type_s, true));
        }
예제 #5
0
            internal override DateTime Parse(RedisExecutor executor)
            {
                executor.AssertType(RedisReplyType.MultiBulk);
                executor.AssertSize(2);

                int timestamp    = Int32.Parse(executor.ReadBulkString());
                int microseconds = Int32.Parse(executor.ReadBulkString());

                return(FromTimestamp(timestamp, microseconds));
            }
예제 #6
0
 internal override T[] Parse(RedisExecutor executor)
 {
     executor.AssertType(RedisReplyType.MultiBulk);
     if (executor.ReadInteger(false) != 2)
     {
         throw new RedisProtocolException("预期返回 2 个项。");
     }
     this.Cursor = Int64.Parse(executor.ReadBulkString());
     return(base.Parse(executor));
 }
예제 #7
0
            internal override Double?Parse(RedisExecutor executor)
            {
                var result = executor.ReadBulkString();

                if (result == null)
                {
                    return(null);
                }
                return(RedisFloat.FromString(result));
            }
예제 #8
0
            internal override Int64?Parse(RedisExecutor executor)
            {
                var type = executor.ReadType();

                if (type == RedisReplyType.Integer)
                {
                    return(executor.ReadInteger(false));
                }
                executor.ReadBulkString(false);
                return(null);
            }
예제 #9
0
            internal override bool Parse(RedisExecutor executor)
            {
                var type = executor.ReadType(false);
                var str  = executor.ReadLine();

                if (type == RedisReplyType.Error)
                {
                    return(false);
                }

                return(Int64.Parse(str) == 1);
            }
예제 #10
0
        internal override T Parse(RedisExecutor executor)
        {
            if (this._checkType)
            {
                executor.AssertType(RedisReplyType.MultiBulk);
                executor.AssertSize(2);
            }
            T item = (T)Activator.CreateInstance(typeof(T), true);

            item.Parse(executor);
            return(item);
        }
예제 #11
0
        internal override BinaryValue Parse(RedisExecutor executor)
        {
            var type = executor.ReadType();

            if (type == RedisReplyType.Bulk)
            {
                var bytes = executor.ReadBulk(false);
                if (bytes == null || bytes.Length == 0)
                {
                    return(null);
                }
                return(new BinaryValue(bytes));
            }

            executor.AssertType(RedisReplyType.MultiBulk, type);
            executor.AssertSize(-1);
            return(null);
        }
예제 #12
0
            internal override bool Parse(RedisExecutor executor)
            {
                var type = executor.ReadType();

                if (type == RedisReplyType.Status)
                {
                    if (executor.ReadStatus(false).IsSucceed)
                    {
                        return(true);
                    }
                    return(false);
                }
                object[] result = executor.ReadMultiBulk(false);
                if (result != null)
                {
                    throw new RedisProtocolException("预期空的多条批量回复,实际出现未知回复。 ");
                }

                return(false);
            }
예제 #13
0
 internal override Result Parse(RedisExecutor executor)
 {
     return(executor.ReadStatus());
 }
예제 #14
0
 internal override string Parse(RedisExecutor executor)
 {
     return(executor.ReadBulkString());
 }
예제 #15
0
 internal override Int64 Parse(RedisExecutor executor)
 {
     return(executor.ReadInteger());
 }
예제 #16
0
 void IRedisItem.Parse(RedisExecutor executor)
 {
     this._Member = executor.ReadBulk();
     this._Score = Aoite.Redis.Commands.RedisFloat.FromString(executor.ReadBulkString());
 }
예제 #17
0
 internal abstract object ObjectParse(RedisExecutor executor);
예제 #18
0
 internal override bool Parse(RedisExecutor executor)
 {
     return(executor.ReadInteger() == 1);
 }
예제 #19
0
 internal override object Parse(RedisExecutor executor)
 {
     return(executor.ReadObject());
 }
예제 #20
0
 internal override DateTime Parse(RedisExecutor executor)
 {
     return(FromTimestamp(executor.ReadInteger()));
 }
예제 #21
0
 internal abstract T Parse(RedisExecutor executor);
예제 #22
0
 internal override object ObjectParse(RedisExecutor executor)
 {
     return(Parse(executor));
 }
예제 #23
0
 internal override Result Parse(RedisExecutor executor)
 {
     return(executor.ReadStatus(statusText: "PONG"));
 }
예제 #24
0
 void IRedisItem.Parse(RedisExecutor executor)
 {
     this._Field = executor.ReadBulkString();
     this._Value = executor.ReadBulk();
 }
예제 #25
0
 internal override Double Parse(RedisExecutor executor)
 {
     return(FromString(executor.ReadBulkString()));
 }