“IE” script context

Each script context contains its own global object, distinct from the global object in other script contexts.

Many Chakra hosting APIs require an "active" script context, which can be set using Current. Chakra hosting APIs that require a current context to be set will note that explicitly in their documentation.

コード例 #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);
                }
            });
        }
コード例 #2
0
        public override object Evaluate(string expression)
        {
            object result = InvokeScript(() =>
            {
                IeJsValue resultValue = IeJsContext.RunScript(expression);

                return(MapToHostType(resultValue));
            });

            return(result);
        }
コード例 #3
0
        public override object Evaluate(string expression, string documentName)
        {
            object result = InvokeScript(() =>
            {
                IeJsValue resultValue = IeJsContext.RunScript(expression, _jsSourceContext++, documentName);

                return(MapToHostType(resultValue));
            });

            return(result);
        }
コード例 #4
0
        protected override void InnerStartDebugging()
        {
            if (Utils.Is64BitProcess())
            {
                var processDebugManager64 = (IProcessDebugManager64) new ProcessDebugManager();
                IDebugApplication64 debugApplication64;
                processDebugManager64.GetDefaultApplication(out debugApplication64);

                IeJsContext.StartDebugging(debugApplication64);
            }
            else
            {
                var processDebugManager32 = (IProcessDebugManager32) new ProcessDebugManager();
                IDebugApplication32 debugApplication32;
                processDebugManager32.GetDefaultApplication(out debugApplication32);

                IeJsContext.StartDebugging(debugApplication32);
            }
        }
コード例 #5
0
 public override void Execute(string code, string documentName)
 {
     InvokeScript(() => IeJsContext.RunScript(code, _jsSourceContext++, documentName));
 }
コード例 #6
0
 public override void Execute(string code)
 {
     InvokeScript(() => IeJsContext.RunScript(code));
 }
コード例 #7
0
 internal static extern JsErrorCode JsCreateContext(IeJsRuntime runtime, IDebugApplication32 debugSite, out IeJsContext newContext);
コード例 #8
0
 internal static extern JsErrorCode JsContextRelease(IeJsContext reference, out uint count);
コード例 #9
0
 internal static extern JsErrorCode JsContextAddRef(IeJsContext reference, out uint count);
コード例 #10
0
 internal static extern JsErrorCode JsSetCurrentContext(IeJsContext context);
コード例 #11
0
 internal static extern JsErrorCode JsSetCurrentContext(IeJsContext context);
コード例 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IeJsScope"/> struct
 /// </summary>
 /// <param name="context">The context to create the scope for</param>
 public IeJsScope(IeJsContext context)
 {
     _disposedFlag = new StatedFlag();
     _previousContext = IeJsContext.Current;
     IeJsContext.Current = context;
 }
コード例 #13
0
 internal static extern JsErrorCode JsGetCurrentContext(out IeJsContext currentContext);
コード例 #14
0
 internal static extern JsErrorCode JsCreateContext(IeJsRuntime runtime, IDebugApplication32 debugSite,
                                                    out IeJsContext newContext);
コード例 #15
0
 internal static extern JsErrorCode JsContextRelease(IeJsContext reference, out uint count);
コード例 #16
0
 internal static extern JsErrorCode JsContextAddRef(IeJsContext reference, out uint count);
コード例 #17
0
 internal static extern JsErrorCode JsGetRuntime(IeJsContext context, out IeJsRuntime runtime);
コード例 #18
0
 internal static extern JsErrorCode JsGetCurrentContext(out IeJsContext currentContext);
コード例 #19
0
 internal static extern JsErrorCode JsGetRuntime(IeJsContext context, out IeJsRuntime runtime);
コード例 #20
0
		/// <summary>
		/// Initializes a new instance of the <see cref="IeJsScope"/> struct
		/// </summary>
		/// <param name="context">The context to create the scope for</param>
		public IeJsScope(IeJsContext context)
		{
			_disposed = false;
			_previousContext = IeJsContext.Current;
			IeJsContext.Current = context;
		}
コード例 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IeJsScope"/> struct
 /// </summary>
 /// <param name="context">The context to create the scope for</param>
 public IeJsScope(IeJsContext context)
 {
     _disposedFlag       = new StatedFlag();
     _previousContext    = IeJsContext.Current;
     IeJsContext.Current = context;
 }