public void AppendList(OperatorInfo op, bool explode, string variable, IList list) { foreach (object item in list) { if (op.Named && explode) { _Result.Append(variable); _Result.Append("="); } AppendValue(item.ToString(), 0, op.AllowReserved); _Result.Append(explode ? op.Seperator : ','); } if (list.Count > 0) { _Result.Remove(_Result.Length - 1, 1); } }
public void AppendDictionary(OperatorInfo op, bool explode, IDictionary<string, string> dictionary) { foreach (string key in dictionary.Keys) { _Result.Append(Encode(key, op.AllowReserved)); if (explode) _Result.Append('='); else _Result.Append(','); AppendValue(dictionary[key], 0, op.AllowReserved); if (explode) { _Result.Append(op.Seperator); } else { _Result.Append(','); } } if (dictionary.Count() > 0) { _Result.Remove(_Result.Length - 1, 1); } }
public VarSpec(OperatorInfo operatorInfo) { _operatorInfo = operatorInfo; }
private void ProcessExpression(StringBuilder currentExpression) { if (currentExpression.Length == 0) { _ErrorDetected = true; _Result.Append("{}"); return; } OperatorInfo op = GetOperator(currentExpression[0]); var firstChar = op.Default ? 0 : 1; bool multivariableExpression = false; var varSpec = new VarSpec(op); for (int i = firstChar; i < currentExpression.Length; i++) { char currentChar = currentExpression[i]; switch (currentChar) { case '*': varSpec.Explode = true; break; case ':': // Parse Prefix Modifier var prefixText = new StringBuilder(); currentChar = currentExpression[++i]; while (currentChar >= '0' && currentChar <= '9' && i < currentExpression.Length) { prefixText.Append(currentChar); i++; if (i < currentExpression.Length) { currentChar = currentExpression[i]; } } varSpec.PrefixLength = int.Parse(prefixText.ToString()); i--; break; case ',': multivariableExpression = true; var success = ProcessVariable(varSpec, multivariableExpression); bool isFirst = varSpec.First; // Reset for new variable varSpec = new VarSpec(op); if (success || !isFirst || _resolvePartially) { varSpec.First = false; } if (!success && _resolvePartially) { _Result.Append(","); } break; default: if (IsVarNameChar(currentChar)) { varSpec.VarName.Append(currentChar); } else { _ErrorDetected = true; } break; } } ProcessVariable(varSpec, multivariableExpression); if (multivariableExpression && _resolvePartially) { _Result.Append("}"); } }
public void AppendName(string variable, OperatorInfo op, bool valueIsEmpty) { _Result.Append(variable); if (valueIsEmpty) { _Result.Append(op.IfEmpty); } else { _Result.Append("="); } }