예제 #1
0
        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);
            }

            try
            {
                _jsEngine.ExecuteFile(path, encoding);
            }
            catch (OriginalJsRuntimeException e)
            {
                throw ConvertMsieJsRuntimeExceptionToJsRuntimeException(e);
            }
        }
        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)
                          );
            }

            try
            {
                _jsEngine.ExecuteFile(path, encoding);
            }
            catch (OriginalException e)
            {
                throw WrapJsException(e);
            }
            catch (FileNotFoundException)
            {
                throw;
            }
        }