Skip to content

Instantly share code, notes, and snippets.

@jrusbatch
Created April 7, 2013 02:24
Show Gist options
  • Save jrusbatch/5328614 to your computer and use it in GitHub Desktop.
Save jrusbatch/5328614 to your computer and use it in GitHub Desktop.
public void Execute(string code, IEnumerable<string> references, IEnumerable<string> namespaces, ScriptPackSession scriptPackSession)
{
var host = _scriptHostFactory.CreateScriptHost(new ScriptPackManager(scriptPackSession.Contexts));
foreach (var context in scriptPackSession.Contexts) _scriptEngine.AddReference(context.GetType().Assembly);
var session = _scriptEngine.CreateSession(host);
foreach (var reference in references.Union(scriptPackSession.References).Distinct())
session.AddReference(reference);
foreach (var @namespace in namespaces.Union(scriptPackSession.Namespaces).Distinct())
session.ImportNamespace(@namespace);
Execute(code, session);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment