object DoStaticMethod(CLRSharp.ThreadContext context, string type, string method) { CLRSharp.ICLRType wt = env.GetType(type); CLRSharp.IMethod methodctor = wt.GetMethod(method, CLRSharp.MethodParamList.constEmpty());//取得构造函数 return(methodctor.Invoke(context, null, null)); }
public static object CreateObject(ThreadContext context, string name) { var wt = HotFixScript.env.GetType(name); CLRSharp.CLRSharp_Instance to = new CLRSharp.CLRSharp_Instance(wt as CLRSharp.ICLRType_Sharp); //创建实例 CLRSharp.IMethod methodctor = wt.GetMethod(".ctor", CLRSharp.MethodParamList.constEmpty()); //取得构造函数 methodctor.Invoke(context, to, null); //执行构造函数 return(to); }
void InvokeMethod(CLRSharp.ThreadContext context, string type, string method) { CLRSharp.ICLRType wt = env.GetType(type); //用全名称,包括命名空间 CLRSharp.CLRSharp_Instance to = new CLRSharp.CLRSharp_Instance(wt as CLRSharp.ICLRType_Sharp); //创建实例 CLRSharp.IMethod methodctor = wt.GetMethod(".ctor", CLRSharp.MethodParamList.constEmpty()); //取得构造函数 methodctor.Invoke(context, to, null); //执行构造函数 CLRSharp.IMethod mt = wt.GetMethod(method, CLRSharp.MethodParamList.constEmpty()); mt.Invoke(context, to, null); }