예제 #1
0
        public string EvaluateProperty(string expression)
        {
            var locator = new Models.PropertyLocator(expression, Model, LoopStack);

            if (locator.Locate() == true)
            {
                var mp = locator.LocatedProperty();

                if (expression.EndsWith("$"))
                {
                    return(mp.Name);
                }
                var result = mp.GetText();

                // replace backslash-quote by quote
                result = result.Replace("\\\"", "\"");
                // replace double backslash by a single backslash
                result = result.Replace("\\\\", "\\");
                // combination of the two properly replaces 3 backslashes and a quote by a backslash and a quote

                return(result);
            }
            else
            {
                throw new ApplicationException(string.Format("Could not evaluate expression {0}", expression));
            }
        }
예제 #2
0
        public void EnterLoop(string expression)
        {
            var iterator = new IteratorManager(new Models.Iterator());

            logger.Trace("Enter loop: " + expression);

            iterator.Path = expression;

            var locator = new Models.PropertyLocator(expression, Model, LoopStack);

            if (locator.Locate() == false)
            {
                throw new ApplicationException(string.Format("Could not understand this loop expression {0}", expression));
            }

            iterator.Root = locator.LocatedProperty();

            LoopStack.Push(iterator);
        }