Inheritance: WebView, IBaseWebView
コード例 #1
0
ファイル: BaseWebView.cs プロジェクト: vhnatyk/WebMarco.2.0
        /// <summary>
        /// Evaluates the expression and returns the value.
        /// </summary>
        /// <param name="webView"></param>
        /// <param name="expression"></param>
        /// <returns></returns>
        public string EvaluateScript(BaseWebView webView, string expression) {
            latch = new CountDownLatch(1);
            string code = "javascript:window." + Name + ".setValue((function(){try{return " + expression
            + "+\"\";}catch(js_eval_err){console.log('js_eval_err : ' + js_eval_err); return '';}})());";
            webView.LoadUrl(code);

            try {
                // Set a 1 second timeout in case there's an error
                latch.Await(1, TimeUnit.Seconds);
                return returnValue;
            } catch (System.Exception ex) {
                DLogger.WriteLog(ex);
            }
            return null;
        }
コード例 #2
0
        /// <summary>
        /// Evaluates the expression and returns the value.
        /// </summary>
        /// <param name="webView"></param>
        /// <param name="expression"></param>
        /// <returns></returns>
        public string EvaluateScript(BaseWebView webView, string expression)
        {
            latch = new CountDownLatch(1);
            string code = "javascript:window." + Name + ".setValue((function(){try{return " + expression
                          + "+\"\";}catch(js_eval_err){console.log('js_eval_err : ' + js_eval_err); return '';}})());";

            webView.LoadUrl(code);

            try {
                // Set a 1 second timeout in case there's an error
                latch.Await(1, TimeUnit.Seconds);
                return(returnValue);
            } catch (System.Exception ex) {
                DLogger.WriteLog(ex);
            }
            return(null);
        }