Skip to content

Get Substitutions before executing the format method #140

Answered by axunonb
panayiotisp asked this question in Q&A
Discussion options

You must be logged in to vote

(like the names) prior to executing the format

If you don't mind executing the formatter with an empty data source, you could get all existing placeholders like shown in the code below.

class Program
{
    private static readonly List<string> _placeholders = new List<string>();
    
    static void Main(string[] args)
    {
        Smart.Default.Settings.FormatErrorAction = ErrorAction.Ignore;
        Smart.Default.Settings.ParseErrorAction = ErrorAction.Ignore;
        Smart.Default.OnFormattingFailure += DefaultOnOnFormattingFailure;
        
        var result = Smart.Format("{few} {placeholders} {that} {cannot} {be} {found}", new Dictionary<string, string>());
        Console.WriteLine

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@panayiotisp
Comment options

@axunonb
Comment options

Answer selected by axunonb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants