public Delegate CreateNewDelegate(Type targetDelegateType, JsFunction jsfunc) { DelegateHolder newHolder = this.holder.New(); newHolder._jsFunc = jsfunc; #if NET20 return(Delegate.CreateDelegate(targetDelegateType, newHolder, this.holder.InvokeMethodInfo)); #else return(this.holder.InvokeMethodInfo.CreateDelegate(targetDelegateType, newHolder)); #endif }
private static void CheckAndResolveJsFunctions(Type type, string methodName, BindingFlags flags, object[] args) { MethodInfo mi = type.GetMethod(methodName, flags); ParameterInfo[] paramTypes = mi.GetParameters(); for (int i = Math.Min(paramTypes.Length, args.Length) - 1; i >= 0; --i) { if (args[i] != null && args[i].GetType() == typeof(JsFunction)) { JsFunction function = (JsFunction)args[i]; args[i] = function.MakeDelegate(paramTypes[i].ParameterType); } } }
static void CheckAndResolveJsFunctions(WeakDelegate weakDel, JsFunction func, object obj, Type type, string methodName, object[] args) { #if NET20 //find proper method BindingFlags flags = BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.FlattenHierarchy; if (weakDel.Target != null) { flags |= BindingFlags.Instance; } else { flags |= BindingFlags.Static; } if (obj is BoundWeakDelegate) { flags |= BindingFlags.NonPublic; } #else #endif MethodInfo foundMet = type.ExtGetMethod(obj, methodName); if (foundMet != null) { } // need to convert methods from JsFunction's into delegates? throw new NotSupportedException(); //MethodInfo mi = type.GetMethod(methodName, flags); //ParameterInfo[] paramTypes = mi.GetParameters(); //for (int i = Math.Min(paramTypes.Length, args.Length) - 1; i >= 0; --i) //{ // if (args[i] != null && args[i].GetType() == typeof(JsFunction)) // { // JsFunction function = (JsFunction)args[i]; // args[i] = function.MakeDelegate(paramTypes[i].ParameterType); // } //} }