public object Invoke() { if (_params.Length != 0) { throw new ArgumentOutOfRangeException(); } return(_appDomain.Invoke(_method, null, null)); }
/// <summary> /// call Method with no params and no return value; /// </summary> /// <param name="Instance">Instacne, if it is null means static method,else means instance method</param> /// <param name="type">TypeName ,eg "Namespace.ClassType"</param> /// <param name="method">MethodName</param> public void Invoke(Object Instance, string type, string method) { Message = new StringBuilder(); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); App.Invoke(type, method, null); //InstanceTest sw.Stop(); Message.AppendLine("Elappsed Time:" + sw.ElapsedMilliseconds + "ms\n"); }
public void HotFixAwake() { if (GameEnvironment.Instance.Platform == GamePlatform.iOS) { appdomain.Invoke(MainClassName, "Main", null, null); } else { m_mainMethod.Invoke(null, null); } }
public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { if (method.HasThis) { var res = appdomain.Invoke(method, obj, parameters); return(res); } else { return(appdomain.Invoke(method, null, parameters)); } }
private void OnILRuntimeInitialized() { #if UNITY_EDITOR || UNITY_ANDROID || UNITY_IPHONE //appdomain.UnityMainThreadID = Thread.CurrentThread.ManagedThreadId; #endif appdomain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter()); CLRRedirection(); string KEY = "委托调用"; switch (KEY) { case "静态调用": { appdomain.Invoke("ILRuntime.Program", "Initialize", null); } break; case "实例调用": { object script = appdomain.Instantiate("ILRuntime.Main"); appdomain.Invoke("ILRuntime.Main", "Test", script); } break; case "反射调用": { var script = appdomain.LoadedTypes["ILRuntime.Main"]; var type = script.ReflectionType; var ctor = type.GetConstructor(new System.Type[0]); var obj = ctor.Invoke(null); var field = type.GetField("index", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); field.SetValue(obj, 123456); var value = field.GetValue(obj); Debug.Log("ID = " + value); } break; default: break; } }
public void RuntimeUpdate(float time) { if (Update != null) { try { _app.Invoke(mainScript.FullName, Update.Name, mainScript); } catch (Exception ex) { Debug.Log(ex.StackTrace); } } }
public IlRuntime(byte[] dat, RectTransform uiRoot) { _app = new ILRuntime.Runtime.Enviorment.AppDomain(); RegDelegate(); using (MemoryStream m = new MemoryStream(dat)) { _app.LoadAssembly(m); } mainScript = _app.GetType("Main") as ILType; var start = mainScript.GetMethod("Start"); if (start != null) { try { _app.Invoke(mainScript.FullName, start.Name, mainScript, uiRoot); } catch (Exception ex) { Debug.Log(ex.StackTrace); } } Update = mainScript.GetMethod("Update"); Resize = mainScript.GetMethod("Resize"); Cmd = mainScript.GetMethod("Cmd"); }
/// <summary> /// 加载Hotfix程序集 /// </summary> /// <param name="dllPath"></param> /// <param name="isRegisterBindings"></param> public static void LoadHotfix(string dllPath, bool isRegisterBindings = true) { // IsRunning = true; string pdbPath = dllPath + ".pdb"; BDebug.Log("DLL加载路径:" + dllPath, "red"); // AppDomain = new AppDomain(); if (File.Exists(pdbPath)) { //这里的流不能释放,头铁的老哥别试了 fsDll = new FileStream(dllPath, FileMode.Open, FileAccess.Read); fsPdb = new FileStream(pdbPath, FileMode.Open, FileAccess.Read); AppDomain.LoadAssembly(fsDll, fsPdb, new PdbReaderProvider()); } else { //这里的流不能释放,头铁的老哥别试了 fsDll = new FileStream(dllPath, FileMode.Open, FileAccess.Read); AppDomain.LoadAssembly(fsDll); } #if UNITY_EDITOR AppDomain.UnityMainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; #endif //绑定的初始化 //ada绑定 AdapterRegister.RegisterCrossBindingAdaptor(AppDomain); //delegate绑定 ILRuntimeDelegateHelper.Register(AppDomain); //值类型绑定 AppDomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); AppDomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); AppDomain.RegisterValueTypeBinder(typeof(Vector4), new Vector4Binder()); AppDomain.RegisterValueTypeBinder(typeof(Quaternion), new QuaternionBinder()); //是否注册各种binding if (isRegisterBindings) { CLRBindings.Initialize(AppDomain); CLRManualBindings.Initialize(AppDomain); // ILRuntime.Runtime.Generated.PreCLRBuilding.Initialize(AppDomain); } JsonMapper.RegisterILRuntimeCLRRedirection(AppDomain); if (BDLauncher.Inst != null && Config.Inst.Data.IsDebuggerILRuntime) { AppDomain.DebugService.StartDebugService(56000); Debug.Log("热更调试器 准备待命~"); } // AppDomain.Invoke("HotfixCheck", "Log", null, null); }
public override object InvokeStatic(string rTypeName, string rMethodName, params object[] rArgs) { if (mApp == null) { return(null); } return(mApp.Invoke(rTypeName, rMethodName, null, rArgs)); }
public object Invoke() { if (ILRTDomain != null) { return(ILRTDomain.Invoke(_method, null, Params)); } return(null); }
public static void LoadHotfix(string dllPath, bool isRegisterBindings = true) { // IsRunning = true; string pdbPath = dllPath.Replace(".dll", ".pdb"); BDebug.Log("DLL加载路径:" + dllPath, "red"); // AppDomain = new AppDomain(); if (File.Exists(pdbPath)) { //这里的流不能释放,头铁的老哥别试了 fsDll = new FileStream(dllPath, FileMode.Open, FileAccess.Read); fsPdb = new FileStream(pdbPath, FileMode.Open, FileAccess.Read); AppDomain.LoadAssembly(fsDll, fsPdb, new PdbReaderProvider()); } else { //这里的流不能释放,头铁的老哥别试了 fsDll = new FileStream(dllPath, FileMode.Open, FileAccess.Read); AppDomain.LoadAssembly(fsDll); } //绑定的初始化 //ada绑定 AdapterRegister.RegisterCrossBindingAdaptor(AppDomain); //delegate绑定 ILRuntimeDelegateHelper.Register(AppDomain); //值类型绑定 AppDomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder()); AppDomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder()); AppDomain.RegisterValueTypeBinder(typeof(Vector4), new Vector4Binder()); AppDomain.RegisterValueTypeBinder(typeof(Quaternion), new QuaternionBinder()); //是否注册各种binding if (isRegisterBindings) { ILRuntime.Runtime.Generated.CLRBindings.Initialize(AppDomain); ILRuntime.Runtime.Generated.CLRManualBindings.Initialize(AppDomain); // ILRuntime.Runtime.Generated.PreCLRBuilding.Initialize(AppDomain); } JsonMapper.RegisterILRuntimeCLRRedirection(AppDomain); if (Application.isEditor) { AppDomain.DebugService.StartDebugService(56000); Debug.Log("热更调试器 准备待命~"); } // AppDomain.Invoke("HotfixCheck", "Log", null, null); }
/// <summary> /// 支付回调 /// </summary> /// <param name="msg">返回的消息-2:其他,-1:取消支付,0:支付失败,1:支付成功</param> public void PayResult(string msg) { //预先获得IMethod,可以减低每次调用查找方法耗用的时间 IType type = AppDomain.LoadedTypes["Hotfix.UIShopComponent"]; object obj = ((ILType)type).Instantiate(); //根据方法名称和参数个数获取方法 IMethod method = type.GetMethod("ShopResult", 1); // 调用 Hotfix 中的支付成功函数 AppDomain.Invoke(method, obj, msg); }
/// <summary> /// 开始执行热更新层代码 /// </summary> public void HotfixStart() { string typeFullName = "Trinity.Hotfix.HotfixEntry"; IType type = AppDomain.LoadedTypes[typeFullName]; object hotfixInstance = ((ILType)type).Instantiate(); AppDomain.Invoke(typeFullName, "Start", hotfixInstance, null); m_Update = new ILInstanceMethod(hotfixInstance, typeFullName, "Update", 2); m_ShutDown = new ILInstanceMethod(hotfixInstance, typeFullName, "ShutDown", 0); }
public void ExecuteMethod(ILClassInstance classInstance, string methodName, int paramCount, params object[] paras) { if (classInstance.classInstance == null || classInstance.type == null) { return; } IMethod method = classInstance.type.GetMethod(methodName, paramCount); appdomain.Invoke(method, classInstance.classInstance, paras); }
public static void LoadHotfix(string root) { if (AppDomain != null) { //AppDomain.FreeILIntepreter(AppDomain.); } // IsRunning = true; string dllPath = root + "/" + Utils.GetPlatformPath(Application.platform) + "/hotfix/hotfix.dll"; string pdbPath = root + "/" + Utils.GetPlatformPath(Application.platform) + "/hotfix/hotfix.pdb"; BDebug.Log("DLL加载路径:" + dllPath, "red"); // AppDomain = new AppDomain(); if (File.Exists(pdbPath)) { var dllfs = File.ReadAllBytes(dllPath); var pdbfs = File.ReadAllBytes(pdbPath); using (MemoryStream dll = new MemoryStream(dllfs)) { using (MemoryStream pdb = new MemoryStream(pdbfs)) { AppDomain.LoadAssembly(dll, pdb, new PdbReaderProvider()); } } } else { UnityWebRequest request; using (System.IO.FileStream fs = new System.IO.FileStream(dllPath, FileMode.Open, FileAccess.Read)) { AppDomain.LoadAssembly(fs); } } //绑定的初始化 AdapterRegister.RegisterCrossBindingAdaptor(AppDomain); ILRuntime.Runtime.Generated.CLRBindings.Initialize(AppDomain); ILRuntime.Runtime.Generated.CLRManualBindings.Initialize(AppDomain); // ILRuntime.Runtime.Generated.PreCLRBuilding.Initialize(AppDomain); // ILRuntimeDelegateHelper.Register(AppDomain); JsonMapper.RegisterILRuntimeCLRRedirection(AppDomain); if (Application.isEditor) { AppDomain.DebugService.StartDebugService(56000); Debug.Log("热更调试器 准备待命~"); } // AppDomain.Invoke("HotfixCheck", "Log", null, null); }
public static void LoadHotfix(string root, bool isRegisterBindings = true) { // IsRunning = true; string dllPath = root + "/" + Utils.GetPlatformPath(Application.platform) + "/hotfix/hotfix.dll"; string pdbPath = root + "/" + Utils.GetPlatformPath(Application.platform) + "/hotfix/hotfix.pdb"; BDebug.Log("DLL加载路径:" + dllPath, "red"); // AppDomain = new AppDomain(); if (File.Exists(pdbPath)) { //这里的流不能释放,头铁的老哥别试了 fsDll = new FileStream(dllPath, FileMode.Open, FileAccess.Read); fsPdb = new FileStream(pdbPath, FileMode.Open, FileAccess.Read); AppDomain.LoadAssembly(fsDll, fsPdb, new PdbReaderProvider()); } else { //这里的流不能释放,头铁的老哥别试了 fsDll = new FileStream(dllPath, FileMode.Open, FileAccess.Read); AppDomain.LoadAssembly(fsDll); } //绑定的初始化 AdapterRegister.RegisterCrossBindingAdaptor(AppDomain); ILRuntimeDelegateHelper.Register(AppDomain); //是否注册各种binding if (isRegisterBindings) { ILRuntime.Runtime.Generated.CLRBindings.Initialize(AppDomain); ILRuntime.Runtime.Generated.CLRManualBindings.Initialize(AppDomain); // ILRuntime.Runtime.Generated.PreCLRBuilding.Initialize(AppDomain); } JsonMapper.RegisterILRuntimeCLRRedirection(AppDomain); if (Application.isEditor) { AppDomain.DebugService.StartDebugService(56000); Debug.Log("热更调试器 准备待命~"); } // AppDomain.Invoke("HotfixCheck", "Log", null, null); }
public void Start(Transform uiRoot, string Cmd, object data) { if (start != null) { try { _app.Invoke(mainScript.FullName, start.Name, mainScript, uiRoot, Cmd, data); } catch (Exception ex) { Debug.Log(ex.StackTrace); } } }
/// <summary> /// 加载Hotfix程序集 /// </summary> /// <param name="dllPath"></param> /// <param name="gamelogicBindAction">游戏逻辑测注册</param> /// <param name="isRegisterBindings"></param> public static void LoadHotfix(string dllPath, Action <bool> gamelogicBindAction = null, bool isRegisterBindings = true) { // IsRunning = true; BDebug.Log("DLL加载路径:" + dllPath, "red"); // string pdbPath = dllPath + ".pdb"; AppDomain = new AppDomain(); if (File.Exists(pdbPath)) { //这里的流不能释放,头铁的老哥别试了 fsDll = new FileStream(dllPath, FileMode.Open, FileAccess.Read); fsPdb = new FileStream(pdbPath, FileMode.Open, FileAccess.Read); AppDomain.LoadAssembly(fsDll, fsPdb, new PdbReaderProvider()); } else { //这里的流不能释放,头铁的老哥别试了 fsDll = new FileStream(dllPath, FileMode.Open, FileAccess.Read); AppDomain.LoadAssembly(fsDll); } #if UNITY_EDITOR AppDomain.UnityMainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; #endif // gamelogicBindAction?.Invoke(isRegisterBindings); // JsonMapper.RegisterILRuntimeCLRRedirection(AppDomain); if (BDLauncher.Inst != null && BDLauncher.Inst.GameConfig.IsDebuggerILRuntime) { AppDomain.DebugService.StartDebugService(56000); Debug.Log("热更调试器 准备待命~"); } // AppDomain.Invoke("HotfixCheck", "Log", null, null); }
private object ILInvoke(out bool succesed, string klass, string method, object host, params object[] args) { var type = mDomain.GetType(klass); if (type == null) { succesed = false; return(null); } var mi = type.GetMethod(method, args != null? args.Length : 0); if (mi == null) { succesed = false; return(null); } succesed = true; return(mDomain.Invoke(mi, host, args)); //return mDomain.Invoke(klass, method, host, args); }
public object Invoke(params object[] args) { try { var target = this.Target; if (target == null) { return(null); } return(appdomain.Invoke(this.method, target, args)); } catch (Exception e) { if (log.IsWarnEnabled) { log.WarnFormat("{0}", e); } } return(null); }
public void BeginExit(Action <Exception> onExit) { appdomain.Invoke(methodMap["BeginExit"], this.ilrobject, new object[] { onExit }); }
void OnILRuntimeInitialized() { appdomain.Invoke("XMoat.Hotfix.Init", "Start", null, null); Log.Info($"Hotfix.OnILRuntimeInitialized: Invoke = XMoat.Hotfix.Init.Start"); }
public override void Invoke(string clsName, string methodName) { _appdomain.Invoke(clsName, methodName, null, null); }
public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) { return(appdomain.Invoke(getter, obj, null)); }
public override void Run() { m_AppDomain.Invoke(this.m_Method, Instance, Param); }
public override void Run(params object[] args) { appDomain.Invoke(method, instance, args); }
//调用方法,如果是抽象方法或者虚方法,尽量不要用这个,因为会有不存在重写的情况,需要调用父类的方法 public object Invoke(int index, params object[] p) { var method = GetMethod(index); return(AppDomain.Invoke(method, ILInstance, p)); }
override public void CallMethod() { if (mApp == null || mMethod == null) return; mApp.Invoke(mMethod, mTarget, null); }
public void OnHotFixLoaded() { Debug.Log("Run DLL!"); appdomain.Invoke("RunTimeFrame.Platform", "Main", null, null); }
public unsafe void OnHotfixLoaded() { appDomain.Invoke("LccHotfix.Init", "InitHotfix", null, null); }