static String GetPropertyName(RESPObject obj, Int32 index) { if (!RESPString.IsString(obj.Header)) { throw new RedisClientBindingException("Element at index " + index + " must be an string in order to be a member name"); } return(obj.GetString()); }
internal static String GetString(this RESPObject obj) { if (RESPString.IsString(obj.Header)) { return(obj.ToString()); } else { throw new RedisClientCastException("Type '" + obj.GetType().Name + "' cannot be cast to 'String'"); } }
static void SetQueuedAsDiscarded(RESPObject[] results, String[] commandHeaders, ref Int32 i) { while (i >= 0 && !commandHeaders[i].Equals("MULTI", StringComparison.Ordinal)) { var element = results[i]; if (RESPString.IsString(element.Header) && RESPString.Same(element, "QUEUED")) { results[i] = RESPSimpleString.DISCARDED; } i--; } }
public void AssertOK() { CheckException(); if (!RESPString.IsString(_response.Header)) { throw new RedisClientAssertException("Expected result for command was 'OK' but a '" + this.RedisType + "' was received instead"); } var value = _response.GetString(); if (!"OK".Equals(value, StringComparison.Ordinal)) { throw new RedisClientAssertException("Expected result for command was 'OK' but result was '" + (value ?? "<null>") + "'"); } }
internal static Double AsDouble(this RESPObject obj) { if (RESPString.IsString(obj.Header)) { var val = obj.ToString(); return(String.IsNullOrWhiteSpace(val) ? 0 : Double.Parse(val, RESPObject.FormatInfo)); } else if (obj.Header == RESPHeaders.Integer) { return(((RESPInteger)obj).Value); } else { throw new RedisClientCastException("Type '" + obj.GetType().Name + "' cannot be formatted as 'Double'"); } }
static int ZipUpResults(RESPObject[] results, Int32 index, RESPObject result) { var array = result.Cast <RESPArray>(); results[index] = RESPSimpleString.OK; index--; var arrayIndex = array.Count - 1; while (index >= 0 && arrayIndex >= 0) { var element = results[index]; if (RESPString.IsString(element.Header) && RESPString.Same(element, "QUEUED")) { results[index] = array[arrayIndex]; arrayIndex--; } index--; } return(index); }