CreateContext() public method

Creates a script context for running scripts
Each script context has its own global object that is isolated from all other script contexts.
public CreateContext ( ) : IeJsContext
return IeJsContext
Esempio n. 1
0
        /// <summary>
        /// Constructs an instance of the Chakra “IE” JsRT JavaScript engine
        /// </summary>
        /// <param name="enableDebugging">Flag for whether to enable script debugging features</param>
        public ChakraIeJsRtJsEngine(bool enableDebugging)
            : base(JsEngineMode.ChakraIeJsRt, enableDebugging)
        {
            _dispatcher.Invoke(() =>
            {
                try
                {
                    _jsRuntime = CreateJsRuntime();
                    _jsContext = _jsRuntime.CreateContext();
                }
                catch (JsUsageException e)
                {
                    string errorMessage;
                    if (e.ErrorCode == JsErrorCode.WrongThread)
                    {
                        errorMessage = CommonStrings.Runtime_JsEnginesConflictOnMachine;
                    }
                    else
                    {
                        errorMessage = string.Format(CommonStrings.Runtime_IeJsEngineNotLoaded,
                                                     _engineModeName, LOWER_IE_VERSION, e.Message);
                    }

                    throw new JsEngineLoadException(errorMessage, _engineModeName);
                }
                catch (Exception e)
                {
                    throw new JsEngineLoadException(
                        string.Format(CommonStrings.Runtime_IeJsEngineNotLoaded,
                                      _engineModeName, LOWER_IE_VERSION, e.Message), _engineModeName);
                }
            });
        }