protected override object InnerEvaluate(string expression, string documentName) { object result; string uniqueDocumentName = GetUniqueDocumentName(documentName, false); lock (_executionSynchronizer) { try { var source = new OriginalStringScriptSource(expression, uniqueDocumentName); result = _jsEngine.Evaluate(source); } catch (OriginalJsException e) { throw ConvertJavascriptExceptionToJsRuntimeException(e); } catch (NotImplementedException e) { throw new JsRuntimeException(e.Message, e); } } result = MapToHostType(result); return(result); }
protected override void InnerExecute(string code, string documentName) { string uniqueDocumentName = GetUniqueDocumentName(documentName, false); lock (_executionSynchronizer) { try { var source = new OriginalStringScriptSource(code, uniqueDocumentName); _jsEngine.Execute(source); } catch (OriginalJavaScriptException e) { throw WrapJavaScriptException(e); } } }
protected override IPrecompiledScript InnerPrecompile(string code, string documentName) { OriginalCompiledScript compiledScript; string uniqueDocumentName = GetUniqueDocumentName(documentName, false); lock (_executionSynchronizer) { try { var source = new OriginalStringScriptSource(code, uniqueDocumentName); compiledScript = _jsEngine.Compile(source); } catch (OriginalSyntaxException e) { throw WrapSyntaxException(e); } } return(new JurassicPrecompiledScript(compiledScript)); }
protected override void InnerExecute(string code, string documentName) { string uniqueDocumentName = GetUniqueDocumentName(documentName, false); lock (_executionSynchronizer) { try { var source = new OriginalStringScriptSource(code, uniqueDocumentName); _jsEngine.Execute(source); } catch (OriginalJsException e) { throw ConvertJavascriptExceptionToJsRuntimeException(e); } catch (NotImplementedException e) { throw new JsRuntimeException(e.Message, e); } } }
protected override object InnerEvaluate(string expression, string documentName) { object result; string uniqueDocumentName = GetUniqueDocumentName(documentName, false); lock (_executionSynchronizer) { try { var source = new OriginalStringScriptSource(expression, uniqueDocumentName); result = _jsEngine.Evaluate(source); } catch (OriginalJavaScriptException e) { throw WrapJavaScriptException(e); } } result = MapToHostType(result); return(result); }
public TextReader loadJS(string filename) { List <string> lines = new List <string>(); string code = ""; try { //Pass the file path and file name to the StreamReader constructor StreamReader sr = new StreamReader(filename); //Read the first line of text string line = sr.ReadLine(); //Continue to read until you reach end of file while (line != null) { //write the lie to console window lines.Add(line); code = code + line; //Read the next line line = sr.ReadLine(); } //close the file sr.Close(); Console.ReadLine(); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } finally { Console.WriteLine("Executing finally block."); } Jurassic.StringScriptSource script = new Jurassic.StringScriptSource(code); return(script.GetReader()); }