Beispiel #1
0
        /// <summary>
        /// Creates a new <see cref="JsExecutionContext"/> instance.
        /// </summary>
        public JsExecutionContext(JavaScriptRuntime runtime)
        {
            _runtime = runtime;
            _scope   = new JsContextScope(_runtime.CreateContext());
            _binder  = new JsBinder(_scope);
            _interop = new JsInterop(this, _scope, _binder);

            _scope.Run(() =>
            {
                _global = new JsBinding(_scope, _binder, _interop, JavaScriptValue.GlobalObject);
            });
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new <see cref="JsModule"/> instance.
        /// </summary>
        public JsModule(JsContextScope scope, JsBinder binder, JsInterop interop, string moduleId)
        {
            _scope   = scope;
            _binder  = binder;
            _interop = interop;

            ModuleId = moduleId;

            // Create JS Representation
            Module = _scope.Run(() =>
            {
                var jsValue = JavaScriptValue.CreateObject();
                jsValue.AddRef();

                return(new JsBinding(_scope, _binder, _interop, jsValue));
            });
        }