Exemplo n.º 1
0
        /// <summary>
        ///     Creates a script context for running scripts.
        /// </summary>
        /// <remarks>
        ///     Each script context has its own global object that is isolated from all other script
        ///     contexts.
        /// </remarks>
        /// <returns>The created script context.</returns>
        public JavaScriptContext CreateContext()
        {
            JavaScriptContext reference;

            Native.ThrowIfError(Native.JsCreateContext(this, out reference));
            return(reference);
        }
Exemplo n.º 2
0
        public string Init(JavaScriptRuntimeAttributes jsrt = JavaScriptRuntimeAttributes.None)
        {
            JavaScriptContext context;

            Native.ThrowIfError(Native.JsCreateRuntime(jsrt, null, out runtime));
            Native.ThrowIfError(Native.JsCreateContext(runtime, out context));
            ResetContext(context);

            // ES6 Promise callback
            JavaScriptPromiseContinuationCallback promiseContinuationCallback = delegate(JavaScriptValue task, IntPtr callbackState)
            {
                taskQueue.Enqueue(task);
            };

            if (Native.JsSetPromiseContinuationCallback(promiseContinuationCallback, IntPtr.Zero) != JavaScriptErrorCode.NoError)
            {
                return("failed to setup callback for ES6 Promise");
            }

            foreach (var one in AllowNameSpace)
            {
                Native.ThrowIfError(Native.JsProjectWinRTNamespace(one));
            }

            if (Native.JsStartDebugging() != JavaScriptErrorCode.NoError)
            {
                return("failed to start debugging.");
            }

            return("NoError");
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Creates a script context for running scripts.
        /// </summary>
        /// <remarks>
        ///     Each script context has its own global object that is isolated from all other script
        ///     contexts.
        /// </remarks>
        /// <returns>The created script context.</returns>
        public JavaScriptContext CreateContext()
        {
            JavaScriptContext reference;

            Native.ThrowIfError(
                Environment.Is64BitProcess
                    ? Native.JsCreateContext(this, (Native.IDebugApplication64)null, out reference)
                    : Native.JsCreateContext(this, (Native.IDebugApplication32)null, out reference));
            return(reference);
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Creates a debug script context for running scripts.
        /// </summary>
        /// <remarks>
        ///     Each script context has its own global object that is isolated from all other script
        ///     contexts.
        /// </remarks>
        /// <param name="debugApplication">The debug application to use.</param>
        /// <returns>The created script context.</returns>
        public JavaScriptContext CreateContext(Native.IDebugApplication32 debugApplication)
        {
            JavaScriptContext reference;

            if (Environment.Is64BitProcess)
            {
                throw new InvalidOperationException();
            }
            Native.ThrowIfError(Native.JsCreateContext(this, debugApplication, out reference));
            return(reference);
        }