Ejemplo n.º 1
0
        private string calculateDescription()
        {
            ISpan previous = null;

            return(Spans
                   .Aggregate(
                       new StringBuilder(),
                       (builder, span) =>
            {
                builder.Append(chooseSeparator(previous, span));
                builder.Append(toString(span));
                previous = span;
                return builder;
            })
                   .ToString()
                   .Trim());

            string toString(ISpan span)
            => span is TextSpan text?text.Text.Trim() : string.Empty;

            string chooseSeparator(ISpan first, ISpan second)
            => first is TextSpan && second is TextSpan ? "" : " ";
        }