/// <summary> /// Creates a CallbackFunction from a delegate. /// </summary> /// <param name="script">The script.</param> /// <param name="del">The delegate.</param> /// <param name="accessMode">The access mode.</param> /// <returns></returns> public static CallbackFunction FromDelegate(Script script, Delegate del, InteropAccessMode accessMode = InteropAccessMode.Default) { if (accessMode == InteropAccessMode.Default) accessMode = m_DefaultAccessMode; MethodMemberDescriptor descr = new MethodMemberDescriptor(del.Method, accessMode); return descr.GetCallbackFunction(script, del.Target); }
/// <summary> /// Creates a CallbackFunction from a MethodInfo relative to a function. /// </summary> /// <param name="script">The script.</param> /// <param name="mi">The MethodInfo object.</param> /// <param name="obj">The object to which the function applies, or null for static methods.</param> /// <param name="accessMode">The access mode.</param> /// <returns></returns> /// <exception cref="System.ArgumentException">The method is not static.</exception> public static CallbackFunction FromMethodInfo(Script script, MethodInfo mi, object obj = null, InteropAccessMode accessMode = InteropAccessMode.Default) { if (accessMode == InteropAccessMode.Default) accessMode = m_DefaultAccessMode; var descr = new MethodMemberDescriptor(mi, accessMode); return descr.GetCallbackFunction(script, obj); }
/// <summary> /// Creates a CallbackFunction from a delegate. /// </summary> /// <param name="script">The script.</param> /// <param name="del">The delegate.</param> /// <param name="accessMode">The access mode.</param> /// <returns></returns> public static CallbackFunction FromDelegate(Script script, Delegate del, InteropAccessMode accessMode = InteropAccessMode.Default) { if (accessMode == InteropAccessMode.Default) accessMode = m_DefaultAccessMode; #if NETFX_CORE MethodMemberDescriptor descr = new MethodMemberDescriptor(del.GetMethodInfo(), accessMode); #else MethodMemberDescriptor descr = new MethodMemberDescriptor(del.Method, accessMode); #endif return descr.GetCallbackFunction(script, del.Target); }