示例#1
0
        /// <summary>
        /// 调用C#脚本函数。
        /// </summary>
        /// <param name="type">对象类型。</param>
        /// <param name="method">方法名称。</param>
        /// <param name="args">调用参数。</param>
        /// <returns>脚本执行结果。</returns>
        public object Invoke(string type, string method, params object[] args)
        {
            if (this.m_Assembly == null)
            {
                if (this.CompileException != null)
                {
                    throw this.CompileException;
                }
                else
                {
                    throw new ScriptException("Error: An exception occurred while parsing the script block", null);
                }
            }

            InvodeContext ic = this.GetMethodContext(type, method);

            if (ic.Exception != null)
            {
                throw ic.Exception;
            }

            return(ic.Handler(ic.Method, args));
        }