qualifier is ILineQualifierEvaluatable eval?_qualifier(eval, lines) :
Пример #2
0
        static void TestExpr()
        {
            var e1    = new __opDollarVector2();
            var e2    = new __opDollarVector2();
            var e3    = new __opDollarVector2();
            var plus  = new __opPlus();
            var minus = new __opMinus();

            e1.__arg0 = 5;
            e1.__arg1 = 15;
            e2.__arg0 = 4;
            e2.__arg1 = 16;
            e3.__arg0 = 2;
            e3.__arg1 = 15;

            //(e1 + e2) - e3
            plus.__arg0  = e1;
            plus.__arg1  = e2;
            minus.__arg0 = plus;
            minus.__arg1 = e3;

            Context m = new Context();

            m.__arg0 = ImmutableDictionary <string, Value> .Empty;
            m.__arg1 = ImmutableDictionary <string, Value> .Empty;
            m.__arg2 = ImmutableDictionary <string, Value> .Empty;

            eval ev = new eval();

            ev.__arg0 = minus;
            ev.__arg1 = m;
            ev.Run();

            //5 * (3 - 2)
            __opMul   mulint = new __opMul();
            __opMinus minint = new __opMinus();

            mulint.__arg0 = new __opDollari();
            __opDollari eint1 = new __opDollari();
            __opDollari eint2 = new __opDollari();
            __opDollari eint3 = new __opDollari();

            eint1.__arg0  = 5;
            eint2.__arg0  = 3;
            eint3.__arg0  = 2;
            minint.__arg0 = eint2;
            minint.__arg1 = eint3;
            mulint.__arg0 = eint1;
            mulint.__arg1 = minint;

            eval evint = new eval();

            evint.__arg0 = mulint;
            evint.__arg1 = m;
            evint.Run();

            if (ev.__res.HasValue)
            {
                Console.WriteLine(ev.__res.Value);
            }
            else
            {
                Console.WriteLine("The rule has failed its evaluation");
            }

            if (evint.__res.HasValue)
            {
                Console.WriteLine(evint.__res.Value);
            }
            else
            {
                Console.WriteLine("The rule has failed its evaluation");
            }
        }