internal void ProcessChildren(IEnumerable <TemplateElement> children, ProcessData processData)
 {
     foreach (var element in children)
     {
         var elementProcessor = GetElementProcessor(element);
         elementProcessor.Process(element, processData);
     }
 }
Пример #2
0
        protected override void _Process(CallElement element, ProcessData processData)
        {
            base._Process(element, processData);

            var inputObject = processData.InputPath[element.TypeReference];

            processData.TemplateEngine.Process(inputObject, processData);
        }
        private void Process(Template template, object input, IOutputWriter outputWriter)
        {
            var processingData = new ProcessData
            {
                OutputWriter   = outputWriter,
                TemplateEngine = this
            };

            processingData.InputPath.Add(template.Input.Alias, input);
            ProcessChildren(template.Children, processingData);
        }
Пример #4
0
        protected override void _Process(ForEachElement element, ProcessData processData)
        {
            base._Process(element, processData);

            processData.InputPath.Add(element.Identifier, null);

            var enumerator = GetEnumerator(element.SourceReference, processData);

            while (enumerator.MoveNext())
            {
                processData.InputPath[element.Identifier] = enumerator.Current;
                processData.TemplateEngine.ProcessChildren(element.Children, processData);
            }
            processData.InputPath.Remove(element.Identifier);
        }
        protected override void _Process(MemberReference element, ProcessData processData)
        {
            base._Process(element, processData);

            var parts = element.Member.Split('.');

            if (parts.Length < 2)
            {
                throw new InvalidOperationException("Member reference should have at least 2 parts");
            }

            var targetName   = parts[0];
            var targetObject = processData.InputPath[targetName];

            for (int i = 1; i < parts.Length; i++)
            {
                var property = targetObject.GetType().GetProperty(parts[1]);

                targetObject = property.GetValue(targetObject);
            }

            processData.OutputWriter.Write(targetObject.ToString());
        }
        internal void Process(object input, ProcessData processData)
        {
            var template = _templateFactory.GetTemplate(input);

            if (template == null)
            {
                throw new InvalidOperationException($"Unable to resolve template for object {input.ToString()}");
            }

            bool inputPathAdded = false;

            if (!processData.InputPath.ContainsKey(template.Input.Alias))
            {
                processData.InputPath.Add(template.Input.Alias, input);
                inputPathAdded = true;
            }

            ProcessChildren(template.Children, processData);

            if (inputPathAdded)
            {
                processData.InputPath.Remove(template.Input.Alias);
            }
        }
        protected override void _Process(BreakElement element, ProcessData processData)
        {
            base._Process(element, processData);

            processData.OutputWriter.WriteLn();
        }
Пример #8
0
        protected override void _Process(LiteralText element, ProcessData processData)
        {
            base._Process(element, processData);

            processData.OutputWriter.Write(element.Text);
        }
 protected virtual void _Process(T element, ProcessData processData)
 {
 }
 public void Process(TemplateElement element, ProcessData processData) =>
 _Process((T)element, processData);