示例#1
0
        NativeFunctionCallback _ProxyCallback; // (need to keep a reference)

        /// <summary>
        ///     Registers an invoke handler on the underlying native ObjectTemplate instance, which allows objects to be called like
        ///     a function.
        ///     <para>A proxy delegate is used and stored locally to prevent it from being reclaimed by the
        ///     GC. If you call this method again, the old proxy delegate will be replaced with a new one and registered again on
        ///     the native side. </para>
        /// </summary>
        /// <param name="callback"> A callback that gets invoked when the object is used like a function. </param>
        public void SetCallAsFunctionHandler(JSFunction callback)
        {
            _ProxyCallback = (managedObjectID, isConstructCall, _this, args, argCount) =>
            {
                return(FunctionTemplate._CallBack(managedObjectID, isConstructCall, _this, args, argCount, callback));
            };
            V8NetProxy.SetCallAsFunctionHandler(_NativeObjectTemplateProxy, _ProxyCallback);
        }
示例#2
0
        /// <summary>
        /// Registers an invoke handler on the underlying native ObjectTemplate instance, which allows the object to be called
        /// like a function.
        /// </summary>
        /// <param name="callback">A callback that gets invoked when the object is used like a function.</param>
        public void SetCallAsFunctionHandler(JSFunction callback)
        {
            ManagedJSFunctionCallback proxyCallback = (managedObjectID, isConstructCall, _this, args, argCount) =>
            {
                return(FunctionTemplate._CallBack(managedObjectID, isConstructCall, _this, args, argCount, callback));
            };

            V8NetProxy.SetCallAsFunctionHandler(_NativeObjectTemplateProxy, proxyCallback);
            _Engine._StoreAccessor(_NativeObjectTemplateProxy->ObjectID, "$__InvokeHandler", proxyCallback);
        }