예제 #1
0
        public void CallCustomCollectionProcessor()
        {
            Dictionary<string, object> vars = new Dictionary<string, object>();
            vars["myCollProc"] = new MyTestCollectionProcessor();

            MethodNode mn = new MethodNode();
            mn.Text = "myCollProc";

            IExpression exp = mn;
            int[] input = new int[] {1, 2, 3};
            Assert.AreSame(input, exp.GetValue(input, vars));
        }
예제 #2
0
        public void PerformanceOfMethodEvaluationOnDifferentContextTypes()
        {
            MethodNode mn = new MethodNode();
            mn.Text = "ToString";

            TypeNode nln = new TypeNode();
            nln.Text = "System.Globalization.CultureInfo";

            PropertyOrFieldNode pn = new PropertyOrFieldNode();
            pn.Text = "InvariantCulture";


            Expression exp = new Expression();
            exp.addChild(nln);
            exp.addChild(pn);

            StringLiteralNode sln = new StringLiteralNode();
            sln.Text = "dummy";

            mn.addChild(sln);
            mn.addChild(exp);

            IExpression mnExp = mn;
            Assert.AreEqual("dummy", mnExp.GetValue(0m, null));

            int runs = 10000000;

            StopWatch watch = new StopWatch();
            using (watch.Start("Duration: {0}"))
            {
                for (int i = 0; i < runs; i++)
                {
                    mnExp.GetValue(0m, null);
                }
            }
        }