Ejemplo n.º 1
0
        NodeBase CreateMathNode(SubExpressionType exp)
        {
            ArithemticOperator op            = exp.GetArithmeticOperator();
            OperationType      operationType = OperationType.ADD;

            //Add
            if (op.HasAdd())
            {
                operationType = OperationType.ADD;
            }
            //Subtract
            else if (op.HasSubtract())
            {
                operationType = OperationType.SUBTRACT;
            }
            //Divide
            else if (op.HasDivide())
            {
                operationType = OperationType.DIVIDE;
            }
            //Multiply
            else if (op.HasMultiply())
            {
                operationType = OperationType.MULTIPLY;
            }
            //Power
            else if (op.HasPower())
            {
                operationType = OperationType.POWER;
            }
            //Log : assumes that RHS is the base and LHS is the number.
            else if (op.HasLog())
            {
                operationType = OperationType.LOG;
            }

            ArithmeticNode node = new ArithmeticNode(m_Container);

            node.m_OperationType = operationType;
            node.AddChild(CreateArithmeticNode(exp.GetLHSArithmeticExpression()));
            node.AddChild(CreateArithmeticNode(exp.GetRHSArithmeticExpression()));

            return(node);
        }
Ejemplo n.º 2
0
		NodeBase CreateMathNode(SubExpressionType exp)
		{
			ArithemticOperator op = exp.GetArithmeticOperator();
			OperationType operationType = OperationType.ADD;
			
			//Add
			if (op.HasAdd())
			{
				operationType = OperationType.ADD;
			}
			//Subtract
			else if (op.HasSubtract())
			{
				operationType = OperationType.SUBTRACT;
			}
			//Divide
			else if (op.HasDivide())
			{
				operationType = OperationType.DIVIDE;
			}
			//Multiply
			else if (op.HasMultiply())
			{
				operationType = OperationType.MULTIPLY;
			}
			//Power
			else if (op.HasPower())
			{
				operationType = OperationType.POWER;
			}
			//Log : assumes that RHS is the base and LHS is the number. 
			else if (op.HasLog())
			{
				operationType = OperationType.LOG;
			}
			
			ArithmeticNode node = new ArithmeticNode(m_Container);
			node.m_OperationType = operationType;
			node.AddChild(CreateArithmeticNode(exp.GetLHSArithmeticExpression()));
			node.AddChild(CreateArithmeticNode(exp.GetRHSArithmeticExpression()));
			
			return node;
		}