Beispiel #1
0
        private string ToStringDefault(ParenMode mode)
        {
            bool useParen = mode == ParenMode.Always;

            if (!useParen)
            {
                useParen = mode != ParenMode.Never && _values.Length > 1;
            }
            var sb = new StringBuilder();

            if (useParen)
            {
                sb.Append("(");
            }
            var sj = new StringJoiner(sb, _joinString);

            foreach (var v in _values)
            {
                sj.Add(FormatField() + v.ToString());
            }
            if (useParen)
            {
                sb.Append(")");
            }
            return(sb.ToString());
        }
Beispiel #2
0
        private string ToStringCombinable(ParenMode mode)
        {
            StringBuilder sb = new StringBuilder(FormatField());

            if (_values.Length > 1 || mode == ParenMode.Always)
            {
                sb.Append("(");
            }
            var sj = new StringJoiner(sb, _joinString);

            foreach (var v in _values)
            {
                sj.Add(v.ToString());
            }
            if (_values.Length > 1 || mode == ParenMode.Always)
            {
                sb.Append(")");
            }
            return(sb.ToString());
        }
Beispiel #3
0
        public virtual string ToString(ParenMode mode)
        {
            StringBuilder sb = new StringBuilder();

            if (ShouldUseParens(mode))
            {
                sb.Append("(");
            }
            var sj = new StringJoiner(sb, GetJoinString());

            foreach (var n in children)
            {
                sj.Add(n.ToString(mode));
            }
            if (ShouldUseParens(mode))
            {
                sb.Append(")");
            }
            return(sb.ToString());
        }