Exemple #1
0
        public bool EvaluateConditional(ExecutionContext ctx, string src, int skipFirst = 1)
        {
            MatchCollection c = Constants.Engine.ConditionalTest.Matches(src);

            // Constants.Engine.AllTokens.FirstOrDefault(t => Regex.IsMatch(token, t.Item1));
            // Get Item2 from this - can form a type name, and build, and set content
            // Enqueue these objects
            // while (queue size > 1)
            // deq, add to eval object
            // if eval object can execute, make it do so, enq its return value
            // and so on
            foreach (Match m in c)
            {
                if (skipFirst-- <= 0)
                {
                    var token = m.Value;
                    var tok   = Constants.Engine.AllTokens.FirstOrDefault(t => Regex.IsMatch(token, t.Item1));
                    ExecutionState.Enqueue(CreateExpressionObject(tok.Item2, m.Value));
                }
            }
            return(Execute(ctx).As <bool>(ctx));
        }