예제 #1
0
        public override IDerivation Visit(ExprDouble aExpr, DerivationContext aContext)
        {
            CyclesDetectContext context = aContext as CyclesDetectContext;

            aExpr.Parent = context.Parent;
            CyclesDetectContext newContext = new CyclesDetectContext(aContext as CyclesDetectContext);

            newContext.Parent = aExpr;
            return(base.Visit(aExpr, newContext));
        }
//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);
            }
예제 #3
0
 public virtual IDerivation Visit(ExprDouble aExpr, DerivationContext aContext)
 {
     return(null);
 }
예제 #4
0
        public static Expr toExprArray(NativeArray paramNativeArray)
        {
            List <object> arrayList = new List <object>();
            int           i         = 1;
            bool          @bool     = false;

            foreach (object @object in paramNativeArray.Ids)
            {
                int j = ((int?)@object).Value;
                @object = paramNativeArray.get(j, null);
                if (@object is NativeArray)
                {
                    @bool = true;
                    List <object> arrayList1 = new List <object>();
                    foreach (object object1 in ((NativeArray)@object).Ids)
                    {
                        int k = ((int?)object1).Value;
                        object1 = ((NativeArray)@object).get(k, null);
                        arrayList1.Add(object1);
                    }
                    if (i == 1 && arrayList1.Count != 0)
                    {
                        i = arrayList1.Count;
                    }
                    arrayList.Add(arrayList1);
                }
                else
                {
                    arrayList.Add(@object);
                }
            }
            ExprArray exprArray = new ExprArray(arrayList.Count, i);

            if (!@bool)
            {
                for (sbyte b = 0; b < arrayList.Count; b++)
                {
                    object     @object    = arrayList[b];
                    ExprString exprString = null;
                    if (@object is double?)
                    {
                        exprString = new ExprDouble(((double?)@object).Value);
                    }
                    else if (@object is int?)
                    {
                        ExprInteger exprInteger = new ExprInteger(((int?)@object).Value);
                    }
                    else if (StringUtils.isDecimal(@object.ToString()))
                    {
                        exprString = new ExprDouble((Convert.ToDouble(@object.ToString())));
                    }
                    else if (@object is NativeJavaObject)
                    {
                        object object1 = ((NativeJavaObject)@object).getDefaultValue(typeof(string));
                        if (StringUtils.isDecimal(object1.ToString()))
                        {
                            exprString = new ExprDouble((Convert.ToDouble(object1.ToString())));
                        }
                        else
                        {
                            ExprString exprString1 = new ExprString(object1.ToString());
                        }
                    }
                    else
                    {
                        exprString = new ExprString(@object.ToString());
                    }
                    exprArray.set(b, exprString);
                }
            }
            else
            {
                for (sbyte b = 0; b < arrayList.Count; b++)
                {
                    System.Collections.IList list = (System.Collections.IList)arrayList[b];
                    for (sbyte b1 = 0; b1 < list.Count; b1++)
                    {
                        object     @object    = list[b1];
                        ExprString exprString = null;
                        if (@object is double?)
                        {
                            exprString = new ExprDouble(((double?)@object).Value);
                        }
                        else if (@object is int?)
                        {
                            ExprInteger exprInteger = new ExprInteger(((int?)@object).Value);
                        }
                        else if (StringUtils.isDecimal(@object.ToString()))
                        {
                            exprString = new ExprDouble((Convert.ToDouble(@object.ToString())));
                        }
                        else if (@object is NativeJavaObject)
                        {
                            object object1 = ((NativeJavaObject)@object).getDefaultValue(typeof(string));
                            if (StringUtils.isDecimal(object1.ToString()))
                            {
                                exprString = new ExprDouble((Convert.ToDouble(object1.ToString())));
                            }
                            else
                            {
                                ExprString exprString1 = new ExprString(object1.ToString());
                            }
                        }
                        else
                        {
                            exprString = new ExprString(@object.ToString());
                        }
                        exprArray.set(b, b1, exprString);
                    }
                }
            }
            return(exprArray);
        }
예제 #5
0
        public static Expr toExprArray(object[] paramArrayOfObject)
        {
            List <object> arrayList = new List <object>();
            int           i         = 1;
            bool          @bool     = false;

            foreach (object @object in paramArrayOfObject)
            {
                if (@object is object[])
                {
                    @bool = true;
                    List <object> arrayList1 = new List <object>();
                    foreach (object object1 in (object[])@object)
                    {
                        arrayList1.Add(object1);
                    }
                    if (i == 1 && arrayList1.Count != 0)
                    {
                        i = arrayList1.Count;
                    }
                    arrayList.Add(arrayList1);
                }
                else
                {
                    arrayList.Add(@object);
                }
            }
            ExprArray exprArray = new ExprArray(arrayList.Count, i);

            if (!@bool)
            {
                for (sbyte b = 0; b < arrayList.Count; b++)
                {
                    object     @object    = arrayList[b];
                    ExprString exprString = null;
                    if (@object is double?)
                    {
                        exprString = new ExprDouble(((double?)@object).Value);
                    }
                    else if (@object is int?)
                    {
                        ExprInteger exprInteger = new ExprInteger(((int?)@object).Value);
                    }
                    else if (StringUtils.isDecimal(@object.ToString()))
                    {
                        exprString = new ExprDouble((Convert.ToDouble(@object.ToString())));
                    }
                    else
                    {
                        exprString = new ExprString(@object.ToString());
                    }
                    exprArray.set(b, exprString);
                }
            }
            else
            {
                for (sbyte b = 0; b < arrayList.Count; b++)
                {
                    System.Collections.IList list = (System.Collections.IList)arrayList[b];
                    for (sbyte b1 = 0; b1 < list.Count; b1++)
                    {
                        object     @object    = list[b1];
                        ExprString exprString = null;
                        if (@object is double?)
                        {
                            exprString = new ExprDouble(((double?)@object).Value);
                        }
                        else if (@object is int?)
                        {
                            ExprInteger exprInteger = new ExprInteger(((int?)@object).Value);
                        }
                        else if (StringUtils.isDecimal(@object.ToString()))
                        {
                            exprString = new ExprDouble((Convert.ToDouble(@object.ToString())));
                        }
                        else
                        {
                            exprString = new ExprString(@object.ToString());
                        }
                        exprArray.set(b, b1, exprString);
                    }
                }
            }
            return(exprArray);
        }