void LoadRuntime(ProgramConfiguration config) { _runtime = new mjr.JSRuntime(config); var globalContext = new mdr.DObject(); _runtime.InitGlobalContext(globalContext); _runtime.SetGlobalContext(globalContext); _scripts = new LinkedList<KeyValuePair<string, string>>(); foreach (var s in config.ScriptFileNames) _scripts.AddLast(new KeyValuePair<string, string>(s, _runtime.ReadAllScript(s))); foreach (var s in config.ScriptStrings) { var MD5 = new MD5CryptoServiceProvider(); var key = BitConverter.ToString(MD5.ComputeHash(Encoding.UTF8.GetBytes(s))); _scripts.AddLast(new KeyValuePair<string, string>(key, s)); } }
void LoadRuntime(ProgramConfiguration config) { _runtime = new mjr.JSRuntime(config); var globalContext = new mdr.DObject(); _runtime.InitGlobalContext(globalContext); _runtime.SetGlobalContext(globalContext); _scripts = new LinkedList <KeyValuePair <string, string> >(); foreach (var s in config.ScriptFileNames) { _scripts.AddLast(new KeyValuePair <string, string>(s, _runtime.ReadAllScript(s))); } foreach (var s in config.ScriptStrings) { var MD5 = new MD5CryptoServiceProvider(); var key = BitConverter.ToString(MD5.ComputeHash(Encoding.UTF8.GetBytes(s))); _scripts.AddLast(new KeyValuePair <string, string>(key, s)); } }
public JSFunctionMetadata GetOrAdd(string scriptString, string scriptKey, JSRuntime runtime) { ScriptInfo script; if (runtime.Configuration.EnableParallelLex) { script = InternalAdd(scriptString, scriptKey, runtime); var timer = StartTimer(Instance.Configuration.MeasureTime, "WaitForLex"); script.LexTask.Wait(); StopTimer(timer); } else { if (!Scripts.TryGetValue(scriptKey, out script)) { script = new ScriptInfo(scriptKey, scriptString); script.Metadata = runtime.LoadScriptStringMetadata(scriptString); Scripts.TryAdd(scriptKey, script); } } return(script.Metadata); }