Beispiel #1
0
        /// <summary>
        /// Get the string representation of the <see cref="LiteralText"/>, with escaped characters converted.
        /// Note: The <see cref="Parser"/> puts each escaped character of an input string
        /// into its own <see cref="LiteralText"/> item.
        /// </summary>
        /// <returns>The string representation of the <see cref="LiteralText"/>, with escaped characters converted.</returns>
        public override ReadOnlySpan <char> AsSpan()
        {
            if (Length == 0)
            {
                return(ReadOnlySpan <char> .Empty);
            }

            // The buffer is only for 1 character - each escaped char goes into its own LiteralText
            return(SmartSettings.Parser.ConvertCharacterStringLiterals &&
                   BaseString.AsSpan(StartIndex)[0] == SmartSettings.Parser.CharLiteralEscapeChar
                ? EscapedLiteral.UnEscapeCharLiterals(SmartSettings.Parser.CharLiteralEscapeChar,
                                                      BaseString.AsSpan(StartIndex, Length),
                                                      false, new char[1])
                : BaseString.AsSpan(StartIndex, Length));
        }
Beispiel #2
0
 /// <summary>
 /// Gets the <see cref="ReadOnlySpan{T}"/> representation of this <see cref="FormatItem"/>.
 /// </summary>
 /// <returns>The <see cref="ReadOnlySpan{T}"/> representation of this <see cref="FormatItem"/></returns>
 public virtual ReadOnlySpan <char> AsSpan() => EndIndex <= StartIndex
     ? BaseString.AsSpan(StartIndex)
     : BaseString.AsSpan(StartIndex, Length);