protected internal virtual RedisBytes ExpectBulkStringBytes(RedisCommand command, bool throwException = true) { if (command == null) { throw new ArgumentNullException("command"); } ValidateNotDisposed(); using (var connection = Connect(command.DbIndex, command.Role)) { return(command.ExpectBulkStringBytes(connection, throwException)); } }
protected internal override RedisBytes ExpectBulkStringBytes(RedisCommand command, bool throwException = true) { using (var result = TryToExecuteAsync <RedisBytes>(command, RedisCommandExpect.BulkStringBytes, (string)null)) { if (result.Handled) { return(result.Result); } using (var connection = (result.UsingConnection() ?? Connect(command.DbIndex, command.Role))) { return(command.ExpectBulkStringBytes(connection, throwException)); } } }
protected internal override T Expect <T>(RedisCommand command, RedisCommandExpect expectation, string okIf = null) { using (var connection = Connect()) { switch (expectation) { case RedisCommandExpect.Response: return((T)(object)command.Execute(connection, ThrowOnError)); case RedisCommandExpect.Array: return((T)(object)command.ExpectArray(connection, ThrowOnError)); case RedisCommandExpect.BulkString: return((T)(object)command.ExpectBulkString(connection, ThrowOnError)); case RedisCommandExpect.BulkStringBytes: return((T)(object)command.ExpectBulkStringBytes(connection, ThrowOnError)); case RedisCommandExpect.Double: return((T)(object)command.ExpectDouble(connection, ThrowOnError)); case RedisCommandExpect.GreaterThanZero: return((T)(object)command.ExpectInteger(connection, ThrowOnError)); case RedisCommandExpect.Integer: return((T)(object)command.ExpectInteger(connection, ThrowOnError)); case RedisCommandExpect.MultiDataBytes: return((T)(object)command.ExpectMultiDataBytes(connection, ThrowOnError)); case RedisCommandExpect.MultiDataStrings: return((T)(object)command.ExpectMultiDataStrings(connection, ThrowOnError)); case RedisCommandExpect.Nothing: return((T)(object)command.ExpectNothing(connection, ThrowOnError)); case RedisCommandExpect.NullableDouble: return((T)(object)command.ExpectNullableDouble(connection, ThrowOnError)); case RedisCommandExpect.NullableInteger: return((T)(object)command.ExpectNullableInteger(connection, ThrowOnError)); case RedisCommandExpect.OK: return((T)(object)command.ExpectOK(connection, ThrowOnError)); case RedisCommandExpect.One: return((T)(object)command.ExpectOne(connection, ThrowOnError)); case RedisCommandExpect.SimpleString: if (!okIf.IsEmpty()) { return((T)(object)command.ExpectSimpleString(connection, okIf, ThrowOnError)); } return((T)(object)command.ExpectSimpleString(connection, ThrowOnError)); case RedisCommandExpect.SimpleStringBytes: if (!okIf.IsEmpty()) { return((T)(object)command.ExpectSimpleStringBytes(connection, okIf.ToBytes(), ThrowOnError)); } return((T)(object)command.ExpectSimpleStringBytes(connection, ThrowOnError)); default: throw new RedisException(String.Format("Undefined expectation type, {0}", expectation.ToString("F")), RedisErrorCode.NotSupported); } } }