public override IPrecompiledScript PrecompileFile(string path, Encoding encoding = null)
        {
            VerifyNotDisposed();

            if (path == null)
            {
                throw new ArgumentNullException(
                          nameof(path),
                          string.Format(CoreStrings.Common_ArgumentIsNull, nameof(path))
                          );
            }

            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Common_ArgumentIsEmpty, nameof(path)),
                          nameof(path)
                          );
            }

            if (!ValidationHelpers.CheckDocumentNameFormat(path))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Usage_InvalidFileNameFormat, path),
                          nameof(path)
                          );
            }

            OriginalCompiledScript compiledScript;
            string uniqueDocumentName = GetUniqueDocumentName(path, true);

            lock (_executionSynchronizer)
            {
                try
                {
                    var source = new FileScriptSource(uniqueDocumentName, path, encoding);
                    compiledScript = _jsEngine.Compile(source);
                }
                catch (OriginalSyntaxException e)
                {
                    throw WrapSyntaxException(e);
                }
                catch (FileNotFoundException)
                {
                    throw;
                }
            }

            return(new JurassicPrecompiledScript(compiledScript));
        }
        public override void ExecuteFile(string path, Encoding encoding = null)
        {
            VerifyNotDisposed();

            if (path == null)
            {
                throw new ArgumentNullException(
                          nameof(path),
                          string.Format(CoreStrings.Common_ArgumentIsNull, nameof(path))
                          );
            }

            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Common_ArgumentIsEmpty, nameof(path)),
                          nameof(path)
                          );
            }

            if (!ValidationHelpers.CheckDocumentNameFormat(path))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Usage_InvalidFileNameFormat, path),
                          nameof(path)
                          );
            }

            string uniqueDocumentName = _documentNameManager.GetUniqueName(path);

            lock (_executionSynchronizer)
            {
                try
                {
                    var source = new FileScriptSource(uniqueDocumentName, path, encoding);
                    _jsEngine.Execute(source);
                }
                catch (OriginalJavaScriptException e)
                {
                    throw WrapJavaScriptException(e);
                }
                catch (FileNotFoundException)
                {
                    throw;
                }
            }
        }
        public override void ExecuteFile(string path, Encoding encoding = null)
        {
            VerifyNotDisposed();

            if (path == null)
            {
                throw new ArgumentNullException(
                          "path", string.Format(CoreStrings.Common_ArgumentIsNull, "path"));
            }

            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Common_ArgumentIsEmpty, "path"), "path");
            }

            if (!File.Exists(path))
            {
                throw new FileNotFoundException(
                          string.Format(CoreStrings.Common_FileNotExist, path), path);
            }

            string uniqueDocumentName = GetUniqueDocumentName(path, true);

            lock (_executionSynchronizer)
            {
                try
                {
                    var source = new FileScriptSource(uniqueDocumentName, path, encoding);
                    _jsEngine.Execute(source);
                }
                catch (OriginalJsException e)
                {
                    throw ConvertJavascriptExceptionToJsRuntimeException(e);
                }
            }
        }