Пример #1
0
        private string GenerateText(Expression expression, ExpressionSourceType source)
        {
            IGenerator template = GeneratorFactory.CreateGenerator(_type, _ruleSetValidator);

            //TODO: can most likely remove this templateInitialization and replace with constructor in partial class
            var templateInitialization = new Dictionary <string, object>
            {
                { "objectExpression", expression },
                { "maxDepth", _maxDepth },
            };

            template.Session = templateInitialization;

            //Set the conversion source
            if (source == ExpressionSourceType.Locals)
            {
                template.Converter = _localsConverter;
            }
            else
            {
                template.Converter = _customExpressionConverter;
            }

            template.Initialize();
            template.Clear();

            string transformedText = template.TransformText();

            return(transformedText);
        }