Ejemplo n.º 1
0
        /// <summary>
        /// Create call of given method with given arguments
        /// </summary>
        /// <param name="methodName">Name of method that will be called</param>
        /// <param name="args">Arguments for call</param>
        /// <returns>Created call</returns>
        public Instruction Call(string methodName, Instruction[] args)
        {
            var methodInfo = _helpers.GetMethod(methodName);
            var parameters = methodInfo.Info.GetParameters();

            var argValues = new LinkedList <Instruction>(args);

            if (parameters.Length > 0 && (parameters[0].ParameterType == typeof(Response)))
            {
                //first parameter is response
                if (!(args.Length > 0) || !(args[0].ReturnType == typeof(Response)))
                {
                    //add implicit response param
                    argValues.AddFirst(new ResponseInstruction());
                }
            }
            return(new CallInstruction(methodInfo, argValues.ToArray()));
        }