//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.boris.expr.Expr evaluateVariable(org.boris.expr.IEvaluationContext param1IEvaluationContext, org.boris.expr.ExprVariable param1ExprVariable) throws org.boris.expr.ExprException
            public virtual Expr evaluateVariable(IEvaluationContext param1IEvaluationContext, ExprVariable param1ExprVariable)
            {
                string str1 = param1ExprVariable.Name.ToUpper();

                if (outerInstance.hasAdditionalVariable(str1))
                {
                    return(outerInstance.getAdditionalVariableValue(str1));
                }
                if (outerInstance.localVariablesMap.ContainsKey(str1))
                {
                    return(new ExprDouble(((decimal)outerInstance.localVariablesMap[str1]).doubleValue()));
                }
                string str2 = BoqItemFormulaEvaluator.fieldFromVariable(str1);

                if (string.ReferenceEquals(str2, null))
                {
                    throw new ExprException("Variable " + str1 + " not found");
                }
                object @object = outerInstance.getFieldValue(outerInstance.boqTable, str2);

                if (@object == null)
                {
                    if (BoqItemTable.isFieldDate(str2))
                    {
                        @object = Convert.ToDouble(0.0D);
                    }
                    else
                    {
                        @object = "";
                    }
                }
                ExprBoolean exprBoolean = null;

                if (@object is Number)
                {
                    exprBoolean = new ExprDouble(((Number)@object).doubleValue());
                }
                else if (@object is string)
                {
                    ExprString exprString = new ExprString(@object.ToString());
                }
                else if (@object is DateTime)
                {
                    exprBoolean = new ExprDouble(ExcelDate.toExcelDate(((DateTime)@object).Ticks));
                }
                else if (@object is bool?)
                {
                    exprBoolean = new ExprBoolean(((bool?)@object).Value);
                }
                return(exprBoolean);
            }
            public virtual void valueChanged(Range param1Range, Expr param1Expr)
            {
                string str = BoqItemFormulaEvaluator.fieldFromVariable(param1Range.Dimension1Name);

                if (!string.ReferenceEquals(str, null) && formulaFields.Contains(str + "Formula"))
                {
                    try
                    {
                        object @object = valueFromExpression(param1Expr);
                        if (@object is decimal)
                        {
                            @object = ((decimal)@object).setScale(10, 4);
                        }
                        BlankResourceInitializer.setFieldValue(outerInstance.boqTable, str, @object);
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine("CAN NOT EVALUATE: " + str + " = " + param1Expr + " = " + valueFromExpression(param1Expr));
                        Console.WriteLine(exception.ToString());
                        Console.Write(exception.StackTrace);
                    }
                }
                else
                {
                    ResourceToAssignmentTable resourceToAssignmentTable = (ResourceToAssignmentTable)outerInstance.assignmentsWithFormulasMap[param1Range.Dimension1Name];
                    if (resourceToAssignmentTable != null)
                    {
                        decimal bigDecimal = resourceToAssignmentTable.QuantityPerUnit.setScale(10, 4);
                        object  @object    = valueFromExpression(param1Expr);
                        if (@object is decimal)
                        {
                            decimal bigDecimal1 = (decimal)@object;
                            if (resourceToAssignmentTable.AssignmentResourceTable is nomitech.common.db.local.LaborTable || resourceToAssignmentTable.AssignmentResourceTable is nomitech.common.db.local.EquipmentTable)
                            {
                                bigDecimal1 = bigDecimal1 * (ProjectDBUtil.currentProjectDBUtil().Properties.getHoursFromUnit(resourceToAssignmentTable.AssignmentResourceTable.Unit));
                            }
                            bigDecimal1.setScale(10, 4);
                            if (BigDecimalMath.cmpCheckNulls(bigDecimal, bigDecimal1) != 0)
                            {
                                resourceToAssignmentTable.QuantityPerUnit = bigDecimal1;
                                outerInstance.updatedResourceToAssignmentQtyPerUnitSet.Add(resourceToAssignmentTable);
                                outerInstance.someAssignemntFormulaValueChanged = true;
                            }
                        }
                    }
                }
            }