public static int ValueLength(ParamValue param, int txtMaxLength) { int supplementaryCharsNb = param.Key.ToString().Length + 3; int maxValueLength = Math.Max(0, txtMaxLength - supplementaryCharsNb); int valueLength = Math.Min(maxValueLength, param.Value.Length); return(valueLength); }
public static StringBuilder Format(ParamValue param, StringBuilder sb) { sb.Append(param.Key); sb.Append(EQ); sb.Append(QUOTE); sb.Append(param.Value); sb.Append(QUOTE); return(sb); }
private ChunkBuilder AppendParam(List <string> chunks, ChunkBuilder chunkFormatter, int maxLength, ParamValue param) { ChunkBuilder res = chunkFormatter; while (param != null) { ParamValue next = res.Append(param); if (next != null && next.Equals(param)) { chunks.Add(res.GetValue()); res = new ChunkBuilder(maxLength); } param = next; } return(res); }
public static ParamValue Parse(string param) { Regex regex = new Regex(PARAM_REG_EX); var match = regex.Match(param); ParamValue result = null; if (Enum.TryParse <ParamValue.Param>(match.Groups[KEY_GROUP_NAME].Value, true, out var key)) { var value = match.Groups[VALUE_GROUP_NAME].Value; result = new ParamValue(key, value); } return(result); }
public ParamValue Append(ParamValue param) { int maxParamLength = _maxLength - _sb.Length - (_firstParam ? 0 : 2); int valueLength = maxParamLength < 0 ? 0 : ParamFormatter.ValueLength(param, maxParamLength); ParamValue toAppend = param.First(valueLength); if (toAppend != null) { if (!_firstParam) { _sb.Append(COMMA); _sb.Append(SP); } ParamFormatter.Format(toAppend, _sb); } _firstParam = false; return(param.TrimLeft(valueLength)); }
public ParamValue Concat(ParamValue param) { return(new ParamValue(Key, Value + param.Value)); }