Esempio n. 1
0
 public static string Process(string template, params TokensSet[] tokens)
 {
     var index = 0;
     var token_index = FindFirstToken(template);
     if (!TokenFound(token_index)) return template;
     var source = new TemplateSource(template);
     var rez = new TemplateRezult(template.Length);
     while (TokenFound(token_index))
     {
         rez.Append(source.Substring(from: index, to: token_index - 1));
         var token = ReadTokenAt(source, token_index);
         var token_value = CalculateToken(token, tokens);
         source.Replace(from: token.StartsAt, to: token.EndsAt, value: token_value);
         index = token.StartsAt;
         token_index = FindNextToken(in_template: source, starting_on: index);
     }
     rez.Append(source.Substring(from: index));
     return rez.ToString();
 }