Example #1
0
        internal bool TryGetNext(out LinePair linePair, TemplateLineEvaluationResult lastTemplateLineEvaluationResult)
        {
            bool         result             = false;
            Line         targetLine         = null;
            TemplateLine templateLine       = null;
            bool         targetLineReturned = targetIterator.TryGetNext(out targetLine);

            //If there are no more target lines then escape the current repeating line if there is one
            //and move through the rest of the template.
            if (targetLineReturned == false && lastTemplateLineEvaluationResult != null)
            {
                lastTemplateLineEvaluationResult.EscapeRepeat = true;
            }
            bool templateLineReturned = templateIterator.TryGetNext(out templateLine, lastTemplateLineEvaluationResult);

            if (targetLineReturned || templateLineReturned)
            {
                result   = true;
                linePair = factory.CreateLinePair(targetLine, templateLine);
            }
            else
            {
                linePair = null;
            }
            return(result);
        }
Example #2
0
        internal TemplateEvaluationResult Evaluate(string target, string template)
        {
            TemplateEvaluationResult result = new TemplateEvaluationResult();
            var linePairIterator            = factory.CreateLinePairIterator(target, template);

            LinePair linePair = null;
            TemplateLineEvaluationResult lastTemplateLineEvaluationResult = null;

            while (linePairIterator.TryGetNext(out linePair, lastTemplateLineEvaluationResult))
            {
                var linePairEvaluationResult = linePairEvaluator.EvaluateLinePair(linePair);
                result.Add(linePairEvaluationResult);
                lastTemplateLineEvaluationResult = linePairEvaluationResult.TemplateLineEvaluationResult;
            }
            return(result);
        }
        internal bool TryGetNext(out LinePair linePair, TemplateLineEvaluationResult lastTemplateLineEvaluationResult)
        {
            bool result = false;
            Line targetLine = null;
            TemplateLine templateLine = null;
            bool targetLineReturned = targetIterator.TryGetNext(out targetLine);
            //If there are no more target lines then escape the current repeating line if there is one
            //and move through the rest of the template.
            if (targetLineReturned == false && lastTemplateLineEvaluationResult != null)
                lastTemplateLineEvaluationResult.EscapeRepeat = true;
            bool templateLineReturned = templateIterator.TryGetNext(out templateLine, lastTemplateLineEvaluationResult);

            if (targetLineReturned || templateLineReturned)
            {
                result = true;
                linePair = factory.CreateLinePair(targetLine, templateLine);
            }
            else
            {
                linePair = null;
            }
            return result;
        }