void Initialize() { mMethodCallParser = new MethodCallParser(this); }
private object EvaluateInvocationExpression(Expression expression, List <object> argumentValues, CodeContext codeContext) { string invocation = expression.ToString(); object lastObject = codeContext.ContainerInstance; if (invocation == "System.Math.Max" || invocation == "Math.Max") { return(PrimitiveOperationManager.Self.MaxObjects(argumentValues[0], argumentValues[1])); } else if (invocation == "GetFile" && argumentValues.Count == 1) { ElementRuntime elementRuntime = null; // We're going to have to assume the user means to call GetFile from the current element if (codeContext.ContainerInstance != null) { if (codeContext.ContainerInstance is ElementRuntime) { elementRuntime = codeContext.ContainerInstance as ElementRuntime; } } if (elementRuntime != null) { return(elementRuntime.GetReferencedFileSaveRuntime(argumentValues[0] as string)); } else { return(null); } } else if (invocation == "System.Math.Min" || invocation == "Math.Min") { return(PrimitiveOperationManager.Self.MinObjects(argumentValues[0], argumentValues[1])); } else if (invocation == "InterpolateBetween" || invocation == "this.InterpolateBetween") { MethodCallParser.InterpolateBetween(lastObject as ElementRuntime, argumentValues[0], argumentValues[1], argumentValues[2]); return(null); } else { object caller = GetCaller(expression, codeContext); MethodInfo methodInfo; object toReturn = null; Type[] argumentTypes = new Type[argumentValues.Count]; for (int i = 0; i < argumentValues.Count; i++) { if (argumentValues[i] != null) { argumentTypes[i] = argumentValues[i].GetType(); } } if (TryHandleSpecialCase(expression, argumentValues, argumentTypes, codeContext, invocation, caller, out toReturn)) { // do nothing, toReturn is set } else { GetMethodInfo(expression, argumentValues, argumentTypes, codeContext, invocation, caller, out methodInfo); if (methodInfo != null) { toReturn = methodInfo.Invoke(caller, argumentValues.ToArray()); } } return(toReturn); } //else //{ // throw new NotImplementedException(); //} }