Beispiel #1
0
 /// <summary>
 /// 获取编译后的程序集
 /// </summary>
 /// <param name="className">类名</param>
 /// <returns></returns>
 public Assembly GetAssemblyByScript(string content)
 {
     if (!_useFileComplie)
     {
         return(ScriptComplieEngine.StreamComplier(content, SingleError));
     }
     else
     {
         return(ScriptComplieEngine.FileComplier(content, SingleError));
     }
 }
Beispiel #2
0
        /// <summary>
        /// 编译脚本,生成委托
        /// </summary>
        /// <param name="className">类名</param>
        /// <param name="methodName">方法名</param>
        /// <param name="delegateType">委托类型</param>
        /// <returns></returns>
        public static Delegate GetDelegate <T>(string className, string content, string methodName)
        {
            //获取程序集
            Assembly assembly = ScriptComplieEngine.StreamComplier(content);


            //判空
            if (assembly == null)
            {
                return(null);
            }


            //获取方法委托
            return(AssemblyOperator
                   .Loader(assembly)[className]
                   .GetMethod(methodName)
                   .CreateDelegate(typeof(T)));
        }