private string ProcessTemplate(string templateText, Entity dataSource, OrganizationConfig config, IOrganizationService service, ITracingService tracing) { var tokenRegex = new Regex(@"\${{([\s\S]*?(?=}}))}}", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.Multiline); var tokens = tokenRegex.Matches(templateText) .Cast <Match>() .Select(m => m.Groups[1].Value) .Distinct() .ToList(); tokens.ForEach(token => { tracing.Trace($"Processing token '{token}'"); var processor = new XTLInterpreter(token, dataSource, config, service, tracing); var processed = string.Empty; try { processed = processor.Produce(); } catch (Exception ex) { tracing.Trace($"Exception while processing token {token}, replacing by empty string. Message: {ex.Message}"); } templateText = templateText.Replace($"${{{{{token}}}}}", processed); tracing.Trace($"Replacing token with '{processed}'"); }); return(templateText); }
public XTLProcessor(string unsecure, string secure) { _config = ProcessorConfig.Parse(unsecure); _organizationConfig = OrganizationConfig.Parse(secure); }