예제 #1
0
        /// <summary>Create a token string instance for the given values, or null if the string is empty.</summary>
        /// <param name="lexTokens">The lexical tokens parsed from the raw string.</param>
        /// <param name="context">The available token context.</param>
        /// <param name="path">The path to the value from the root content file.</param>
        public IManagedTokenString?CreateTokenStringOrNull(ILexToken[]?lexTokens, IContext context, LogPathBuilder path)
        {
            if (lexTokens?.Length is null or 0)
            {
                return(null);
            }

            if (lexTokens.Length == 1 && lexTokens[0] is LexTokenLiteral literal)
            {
                return(string.IsNullOrWhiteSpace(literal.Text)
                    ? null
                    : new LiteralString(literal.Text, path));
            }

            return(new TokenString(lexTokens, context, path));
        }
예제 #2
0
 /// <summary>Create a token string instance for the given values.</summary>
 /// <param name="lexTokens">The lexical tokens parsed from the raw string.</param>
 /// <param name="context">The available token context.</param>
 /// <param name="path">The path to the value from the root content file.</param>
 public IManagedTokenString CreateTokenString(ILexToken[] lexTokens, IContext context, LogPathBuilder path)
 {
     return(this.CreateTokenStringOrNull(lexTokens, context, path)
            ?? new LiteralString(string.Empty, path));
 }