Пример #1
0
        /// <summary>
        /// Evaluates an expression
        /// </summary>
        /// <param name="expression">JavaScript expression</param>
        /// <returns>Result of the expression</returns>
        /// <exception cref="System.ObjectDisposedException">Operation is performed on a disposed MSIE
        /// JavaScript engine.</exception>
        /// <exception cref="System.ArgumentException" />
        /// <exception cref="MsieJavaScriptEngine.JsRuntimeException">JavaScript runtime error.</exception>
        public object Evaluate(string expression)
        {
            VerifyNotDisposed();

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

            return(_jsEngine.Evaluate(expression));
        }
Пример #2
0
        /// <summary>
        /// Evaluates an expression
        /// </summary>
        /// <param name="expression">JavaScript expression</param>
        /// <param name="documentName">Document name</param>
        /// <returns>Result of the expression</returns>
        /// <exception cref="System.ObjectDisposedException">Operation is performed on a disposed MSIE
        /// JavaScript engine.</exception>
        /// <exception cref="System.ArgumentException" />
        /// <exception cref="MsieJavaScriptEngine.JsRuntimeException">JavaScript runtime error.</exception>
        public object Evaluate(string expression, string documentName)
        {
            VerifyNotDisposed();

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

            string uniqueDocumentName = _documentNameManager.GetUniqueName(documentName);

            return(_jsEngine.Evaluate(expression, uniqueDocumentName));
        }