//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); }
private Expression ParseIdAccess() { var originProp = PeekToken(); ReadToken(); // read identifier Token unknownProp; if (PeekType() == TokenType.L_PAR) { var expr = ParseFuncCall(originProp); expr = ParseAccess(expr, out unknownProp); if (unknownProp != null) { throw new ParseErrorException( $"Only public properties, constants and enums are accepted. Identifier '{unknownProp.RawValue}' not known.", ExprString, unknownProp.Location); } Debug.Assert(expr != null); return(expr); } else { var expr = ExtractMemberAccessExpression(originProp.RawValue, ContextExpression); expr = ParseAccess(expr, out unknownProp); var start = originProp.Location.Position(ExprString); var length = PeekToken().Location.Position(ExprString) - start; var chain = ExprString.Substring(start, length).TrimEnd(' ', '\t'); if (expr != null) { Fields[chain] = expr; } else { expr = ExtractConstantAccessExpression(chain, originProp.Location); unknownProp = unknownProp ?? originProp; if (expr == null) { throw new ParseErrorException( $"Only public properties, constants and enums are accepted. Identifier '{unknownProp.RawValue}' not known.", ExprString, unknownProp.Location); } } return(expr); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.boris.expr.Expr evaluate(org.boris.expr.IEvaluationContext paramIEvaluationContext, org.boris.expr.Expr[] paramArrayOfExpr) throws org.boris.expr.ExprException public virtual Expr evaluate(IEvaluationContext paramIEvaluationContext, Expr[] paramArrayOfExpr) { ExprString exprString; assertMinArgCount(paramArrayOfExpr, 2); int?integer1; int?integer2 = (integer1 = Convert.ToInt32(asInteger(paramIEvaluationContext, paramArrayOfExpr[0], true))).valueOf(asInteger(paramIEvaluationContext, paramArrayOfExpr[1], true)); if (paramArrayOfExpr.Length > 2) { exprString = paramArrayOfExpr[2]; } else { exprString = new ExprString(""); } return(new BlankExprArray(integer1.Value, integer2.Value, exprString)); }
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); }
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); }