Ejemplo n.º 1
0
        // public BinaryOperator Operator;
        // public Expression Expression1;
        // public Expression Expression2;
        override public int Evaluate(EvaluationState state)
        {
            var value1 = Expression1.Evaluate(state);
            var value2 = Expression2.Evaluate(state);

            var result = 0;

            switch (Operator)
            {
            case BinaryOperator.Add:
                result = value1 + value2;
                break;

            case BinaryOperator.Sub:
                result = value1 - value2;
                break;

            case BinaryOperator.Eq:
                result = value1 == value2 ? 1 : 0;
                break;

            case BinaryOperator.Lt:
                result = value1 < value2 ? 1 : 0;
                break;
            }

            return(result);
        }
Ejemplo n.º 2
0
        // public Expression Expression1;
        // public Expression Expression2;
        override public int Evaluate(EvaluationState state)
        {
            Expression1.Evaluate(state);
            var result = Expression2.Evaluate(state);

            return(result);
        }
Ejemplo n.º 3
0
            public override bool IsMatch(IRequestContext context)
            {
                var value1 = Expression1.Evaluate(context);
                var value2 = Expression2.Evaluate(context);

                if (string.IsNullOrEmpty(value1))
                {
                    return(string.IsNullOrEmpty(value2));
                }
                if (string.IsNullOrEmpty(value2))
                {
                    return(false);
                }

                return(string.Equals(value1, value2, StringComparison.OrdinalIgnoreCase));
            }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var exp = new Expression1(new FileOutput("output.txt"));

            exp.Evaluate();
            var exp2 = new Expression1(30, 40, new ConsoleOutput());

            exp2.Evaluate();
            //var exp3 = new BubbleSort(new ConsoleOutput());
            //var exp3 = new BubbleSort(new FileOutput("output.txt"));
            var exp3 = new BubbleSort(
                new CombinedOutput(
                    new FileOutput("output.txt"),
                    new FileOutput("output2.txt"),
                    new ConsoleOutput()
                    )
                );

            exp3.Evaluate();
            Console.ReadKey();
        }
 internal override double Evaluate()
 {
     return(Expression1.Evaluate() / Expression2.Evaluate());
 }
Ejemplo n.º 6
0
 internal override double Evaluate()
 {
     return(Math.Pow(Expression1.Evaluate(), Expression2.Evaluate()));
 }