コード例 #1
0
        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);
        }
コード例 #2
0
 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);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
 public ParamValue Concat(ParamValue param)
 {
     return(new ParamValue(Key, Value + param.Value));
 }