private object EvaluateExpression(ValueExpression expr, IScriptContext ctx) { try { return(expr.GetValue(CreateElContext(ctx))); } catch (ELException elexp) { throw new ScriptException(elexp); } }
public virtual object GetValue(IVariableContext variableContext) { if (Context.CommandContext == null) { throw new ProcessEngineException( "Expression can only be evaluated inside the context of the process engine"); } var context = Context.ProcessEngineConfiguration.ExpressionManager.CreateElContext(variableContext); return(ValueExpression.GetValue(context)); }
public override object Eval(Bindings bindings, ELContext context) { ValueExpression expression = bindings.GetVariable(index); if (expression != null) { return(expression.GetValue(context)); } context.PropertyResolved = false; object result = context.ELResolver.GetValue(context, null, name); if (!context.PropertyResolved) { throw new PropertyNotFoundException(LocalMessages.Get(string.Format("error.identifier.property.notfound:{0}", name))); } return(result); }
public virtual bool EvaluateSimpleUnaryTests(string simpleUnaryTests, string inputName, IVariableContext variableContext) { try { ELContext elContext = CreateContext(variableContext); ValueExpression valueExpression = TransformSimpleUnaryTests(simpleUnaryTests, inputName, elContext); return((bool)valueExpression.GetValue(elContext)); } catch (FeelMissingFunctionException e) { throw LOG.UnknownFunction(simpleUnaryTests, e); } catch (FeelMissingVariableException e) { if (inputName.Equals(e.GetVariable())) { throw LOG.unableToEvaluateExpressionAsNotInputIsSet(simpleUnaryTests, e); } else { throw LOG.unknownVariable(simpleUnaryTests, e); } } catch (FeelConvertException e) { throw LOG.unableToConvertValue(simpleUnaryTests, e); } catch (ELException e) { if (e.InnerException is FeelMethodInvocationException) { throw LOG.unableToInvokeMethod(simpleUnaryTests, (FeelMethodInvocationException)e.InnerException); } else { throw LOG.unableToEvaluateExpression(simpleUnaryTests, e); } } }
/// <summary> /// 根据初始参数值生成Row,常用来提供给查询面板 /// </summary> /// <returns></returns> public Row BuildInitRow() { var data = new Row(); foreach (var row in Data) { string name = row.Str("name"); if (name == "") { continue; } string val = row.Str("val"); if (val != "" && val[0] == ':') { val = ValueExpression.GetValue(val.Substring(1)); } switch (row.Str("type").ToLower()) { case "bool": if (val == "") { data.AddCell <bool>(name); } else { string l = val.ToLower(); data.AddCell(name, (l == "1" || l == "true")); } break; case "double": if (val != "" && double.TryParse(val, out var v)) { data.AddCell(name, v); } else { data.AddCell <double>(name); } break; case "int": if (val != "" && int.TryParse(val, out var i)) { data.AddCell(name, i); } else { data.AddCell <int>(name); } break; case "date": if (val != "" && DateTime.TryParse(val, out var d)) { data.AddCell(name, d); } else { data.AddCell <DateTime>(name); } break; default: data.AddCell(name, val); break; } } return(data); }
/// <summary> /// 根据初始参数值生成查询参数字典 /// </summary> /// <returns></returns> public Dict BuildInitDict() { Dict dict = new Dict(); foreach (var row in Data) { string name = row.Str("name"); if (name == "") { continue; } string val = row.Str("val"); if (val != "" && val[0] == ':') { val = ValueExpression.GetValue(val.Substring(1)); } switch (row.Str("type").ToLower()) { case "bool": if (val == "") { dict[name] = false; } else { string l = val.ToLower(); dict[name] = (l == "1" || l == "true"); } break; case "double": if (val != "" && double.TryParse(val, out var v)) { dict[name] = v; } else { dict[name] = default(double); } break; case "int": if (val != "" && int.TryParse(val, out var i)) { dict[name] = i; } else { dict[name] = default(int); } break; case "date": if (val != "" && DateTime.TryParse(val, out var d)) { dict[name] = d; } else { dict[name] = default(DateTime); } break; default: dict[name] = val; break; } } return(dict); }
protected override string VisitMemberExpression(MemberExpression memberExpression) => IsMemberExpressionBelongsResource(memberExpression) ? base.VisitMemberExpression(memberExpression) : _valueExpression.GetValue(memberExpression).ToQuery();
protected internal override void Invoke() { InvocationResult = _valueExpression.GetValue(_elContext); }
public Object GetValue(IVariableContext variableContext) { ELContext elContext = elContextFactory.CreateElContext(variableContext); return(expression.GetValue(elContext)); }