public override object invoke(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes, object[] paramValues) { object @base = property.Prefix.eval(bindings, context); if (@base == null) { throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", property.Prefix)); } object method = property.getProperty(bindings, context); if (method == null) { throw new PropertyNotFoundException(LocalMessages.get("error.property.method.notfound", "null", @base)); } string name = bindings.convert(method, typeof(string)); paramValues = @params.eval(bindings, context); context.PropertyResolved = false; object result = context.ELResolver.invoke(context, @base, name, paramTypes, paramValues); if (!context.PropertyResolved) { throw new MethodNotFoundException(LocalMessages.get("error.property.method.notfound", name, @base.GetType())); } // if (returnType != null && !returnType.isInstance(result)) { // should we check returnType for method invocations? // throw new MethodNotFoundException(LocalMessages.get("error.property.method.notfound", name, base.getClass())); // } return(result); }
public override object invoke(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes, object[] paramValues) { object @base = prefix.eval(bindings, context); if (@base == null) { throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", prefix)); } object property = getProperty(bindings, context); if (property == null && strict) { throw new PropertyNotFoundException(LocalMessages.get("error.property.method.notfound", "null", @base)); } string name = bindings.convert(property, typeof(string)); System.Reflection.MethodInfo method = findMethod(name, @base.GetType(), returnType, paramTypes); try { return(method.invoke(@base, paramValues)); } catch (IllegalAccessException) { throw new ELException(LocalMessages.get("error.property.method.access", name, @base.GetType())); } catch (System.ArgumentException e) { throw new ELException(LocalMessages.get("error.property.method.invocation", name, @base.GetType()), e); } catch (InvocationTargetException e) { throw new ELException(LocalMessages.get("error.property.method.invocation", name, @base.GetType()), e.InnerException); } }
/// <summary> /// evaluate and return the (optionally coerced) result. /// </summary> public object getValue(Bindings bindings, ELContext context, Type type) { object value = eval(bindings, context); if (type != null) { value = bindings.convert(value, type); } return(value); }
public override object eval(Bindings bindings, ELContext context) { StringBuilder b = new StringBuilder(16); for (int i = 0; i < Cardinality; i++) { b.Append(bindings.convert(nodes[i].eval(bindings, context), typeof(string))); } return(b.ToString()); }
public override MethodInfo getMethodInfo(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes) { object @base = prefix.eval(bindings, context); if (@base == null) { throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", prefix)); } object property = getProperty(bindings, context); if (property == null && strict) { throw new PropertyNotFoundException(LocalMessages.get("error.property.method.notfound", "null", @base)); } string name = bindings.convert(property, typeof(string)); System.Reflection.MethodInfo method = findMethod(name, @base.GetType(), returnType, paramTypes); return(new MethodInfo(method.Name, method.ReturnType, paramTypes)); }
public override object invoke(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes, object[] paramValues) { return(returnType == null ? value : bindings.convert(value, returnType)); }
/// <summary> /// Invoke method. </summary> /// <param name="bindings"> </param> /// <param name="context"> </param> /// <param name="base"> </param> /// <param name="method"> </param> /// <returns> method result </returns> /// <exception cref="InvocationTargetException"> </exception> /// <exception cref="IllegalAccessException"> </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: protected Object invoke(Bindings bindings, org.camunda.bpm.engine.impl.javax.el.ELContext context, Object super, Method method) throws InvocationTargetException, IllegalAccessException protected internal virtual object invoke(Bindings bindings, ELContext context, object @base, System.Reflection.MethodInfo method) { Type[] types = method.ParameterTypes; object[] @params = null; if (types.Length > 0) { @params = new object[types.Length]; if (varargs && method.VarArgs) { for (int i = 0; i < @params.Length - 1; i++) { object param = getParam(i).eval(bindings, context); if (param != null || types[i].IsPrimitive) { @params[i] = bindings.convert(param, types[i]); } } int varargIndex = types.Length - 1; Type varargType = types[varargIndex].GetElementType(); int length = ParamCount - varargIndex; object array = null; if (length == 1) { // special: eventually use argument as is object param = getParam(varargIndex).eval(bindings, context); if (param != null && param.GetType().IsArray) { if (types[varargIndex].IsInstanceOfType(param)) { array = param; } else { // coerce array elements length = Array.getLength(param); array = Array.CreateInstance(varargType, length); for (int i = 0; i < length; i++) { object elem = Array.get(param, i); if (elem != null || varargType.IsPrimitive) { ((Array)array).SetValue(bindings.convert(elem, varargType), i); } } } } else { // single element array array = Array.CreateInstance(varargType, 1); if (param != null || varargType.IsPrimitive) { ((Array)array).SetValue(bindings.convert(param, varargType), 0); } } } else { array = Array.CreateInstance(varargType, length); for (int i = 0; i < length; i++) { object param = getParam(varargIndex + i).eval(bindings, context); if (param != null || varargType.IsPrimitive) { ((Array)array).SetValue(bindings.convert(param, varargType), i); } } } @params[varargIndex] = array; } else { for (int i = 0; i < @params.Length; i++) { object param = getParam(i).eval(bindings, context); if (param != null || types[i].IsPrimitive) { @params[i] = bindings.convert(param, types[i]); } } } } return(method.invoke(@base, @params)); }
public object eval(Bindings bindings, ELContext context, AstNode left, AstNode right) { bool?l = bindings.convert(left.eval(bindings, context), typeof(Boolean)); return(true.Equals(l) ? bindings.convert(right.eval(bindings, context), typeof(Boolean)) : false); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public Object eval(Bindings bindings, org.camunda.bpm.engine.impl.javax.el.ELContext context) throws org.camunda.bpm.engine.impl.javax.el.ELException public override object eval(Bindings bindings, ELContext context) { bool?value = bindings.convert(question.eval(bindings, context), typeof(Boolean)); return(value.Value ? yes.eval(bindings, context) : no.eval(bindings, context)); }