public ScriptContext Run(string[] siteScriptsFilenames, IDictionary<string, object> givenContext) { ScriptContext context = new ScriptContext(givenContext); foreach (string fn in siteScriptsFilenames) { foreach (KeyValuePair<string, object> kvp in Run(fn.Replace("/", "\\"), context)) { context[kvp.Key] = kvp.Value; } } return context; }
public ScriptContext Run([NotNull] string siteScriptsFilename, [NotNull] IDictionary<string, object> givenContext) { ScriptContext context = new ScriptContext(givenContext); string filename = GetFilename(siteScriptsFilename.Replace("/", "\\")); string filetype = GetFiletype(filename); // load script text string script = Files[filename]; // load engine if (!_engines.ContainsKey(filetype)) throw new ArgumentException("No engine to process filetype " + filetype); IScriptEngine engine = _engines[filetype]; // run in engine context = new ScriptContext(engine.RunScript(script, context)); // return resulting context return context; }