Exemple #1
0
        public static string ProcessTokens(string templateText, Entity dataSource, OrganizationConfig config, IOrganizationService service, ITracingService tracing)
        {
            var tokens = MatchTokens(templateText);

            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 XTLInterpreter(string input, Entity primary, OrganizationConfig organizationConfig, IOrganizationService service, ITracingService tracing)
        {
            _primary            = primary;
            _service            = service;
            _tracing            = tracing;
            _organizationConfig = organizationConfig;

            _reader = new StringReader(input);
            GetChar();
            SkipWhiteSpace();
        }