internal override T[] Parse(RedisExecutor executor) { executor.AssertType(RedisReplyType.MultiBulk); long count = executor.ReadInteger(false); return(Read(count / this._parseItemCount, executor).ToArray()); }
protected virtual IEnumerable <T> Read(long count, RedisExecutor stream) { for (int i = 0; i < count; i++) { yield return(_command.Parse(stream)); } }
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); }
internal override RedisType Parse(RedisExecutor executor) { executor.AssertType(RedisReplyType.Status); var type_s = executor.ReadLine(); return((RedisType)Enum.Parse(REDIS_TYPE, type_s, true)); }
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)); }
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)); }
internal override Double?Parse(RedisExecutor executor) { var result = executor.ReadBulkString(); if (result == null) { return(null); } return(RedisFloat.FromString(result)); }
internal override Int64?Parse(RedisExecutor executor) { var type = executor.ReadType(); if (type == RedisReplyType.Integer) { return(executor.ReadInteger(false)); } executor.ReadBulkString(false); return(null); }
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); }
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); }
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); }
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); }
internal override Result Parse(RedisExecutor executor) { return(executor.ReadStatus()); }
internal override string Parse(RedisExecutor executor) { return(executor.ReadBulkString()); }
internal override Int64 Parse(RedisExecutor executor) { return(executor.ReadInteger()); }
void IRedisItem.Parse(RedisExecutor executor) { this._Member = executor.ReadBulk(); this._Score = Aoite.Redis.Commands.RedisFloat.FromString(executor.ReadBulkString()); }
internal abstract object ObjectParse(RedisExecutor executor);
internal override bool Parse(RedisExecutor executor) { return(executor.ReadInteger() == 1); }
internal override object Parse(RedisExecutor executor) { return(executor.ReadObject()); }
internal override DateTime Parse(RedisExecutor executor) { return(FromTimestamp(executor.ReadInteger())); }
internal abstract T Parse(RedisExecutor executor);
internal override object ObjectParse(RedisExecutor executor) { return(Parse(executor)); }
internal override Result Parse(RedisExecutor executor) { return(executor.ReadStatus(statusText: "PONG")); }
void IRedisItem.Parse(RedisExecutor executor) { this._Field = executor.ReadBulkString(); this._Value = executor.ReadBulk(); }
internal override Double Parse(RedisExecutor executor) { return(FromString(executor.ReadBulkString())); }