public double ToDouble() { return(BlinkBrowserPInvoke.jsToDouble(this.intptr_0, this.long_0)); }
//private static List<jsNativeFunction> jsnaviteList = new List<jsNativeFunction>(); public void BindJsFunc() { if (GlobalObjectJs == null) { GlobalObjectJs = this; } var att = GlobalObjectJs.GetType().GetMethods(); //jsnaviteList.Clear(); var result = new ArrayList(); foreach (var item in att) { var xx = item.GetCustomAttributes(typeof(JSFunctin), true); if (xx != null && xx.Length != 0) { var jsnav = new wkeJsNativeFunction((es, _param) => { var xp = item.GetParameters(); var argcount = BlinkBrowserPInvoke.jsArgCount(es); long param = 0L; if (xp != null && xp.Length != 0 && argcount != 0) { object[] listParam = new object[BlinkBrowserPInvoke.jsArgCount(es)]; for (int i = 0; i < argcount; i++) { Type tType = xp[i].ParameterType; var paramnow = BlinkBrowserPInvoke.jsArg(es, i); param = paramnow; if (tType == typeof(int)) { listParam[i] = Convert.ChangeType(BlinkBrowserPInvoke.jsToInt(es, paramnow), tType); } else if (tType == typeof(double)) { listParam[i] = Convert.ChangeType(BlinkBrowserPInvoke.jsToDouble(es, paramnow), tType); } else if (tType == typeof(float)) { listParam[i] = Convert.ChangeType(BlinkBrowserPInvoke.jsToFloat(es, paramnow), tType); } else if (tType == typeof(bool)) { listParam[i] = Convert.ChangeType(BlinkBrowserPInvoke.jsToBoolean(es, paramnow), tType); } else { listParam[i] = Convert.ChangeType((BlinkBrowserPInvoke.jsToString(es, paramnow)).Utf8IntptrToString(), tType); } } try { var res = item.Invoke(GlobalObjectJs, listParam); if (res != null) { var mStr = Marshal.StringToHGlobalUni(res.ToString()); return(BlinkBrowserPInvoke.jsStringW(es, mStr));//返回JS字符串 } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } else { var res = item.Invoke(GlobalObjectJs, null); if (res != null) { var mStr = Marshal.StringToHGlobalUni(res.ToString()); return(BlinkBrowserPInvoke.jsStringW(es, mStr));//返回JS字符串 } } return(param); }); BlinkBrowserPInvoke.wkeJsBindFunction(item.Name, jsnav, IntPtr.Zero, (uint)item.GetParameters().Length); listObj.Add(jsnav); } } }