Example #1
0
        /// <summary>
        ///     Creates a new JavaScript function.
        /// </summary>
        /// <remarks>
        ///     Requires an active script context.
        /// </remarks>
        /// <param name="function">The method to call when the function is invoked.</param>
        /// <returns>The new function object.</returns>
        public static JavaScriptValue CreateFunction(string name, JavaScriptNativeFunction function)
        {
            JavaScriptValue reference;

            Native.ThrowIfError(Native.JsCreateNamedFunction(FromString(name), function, IntPtr.Zero, out reference));
            return(reference);
        }