Last active
December 20, 2015 06:29
-
-
Save dapngn/6086057 to your computer and use it in GitHub Desktop.
A simple call to the Roslyn api.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private readonly ScriptEngine _engine; | |
public ScriptExecutor() | |
{ | |
_engine = new ScriptEngine(); | |
_engine.AddReference("System"); | |
_engine.AddReference(this.GetType().Assembly.Location); | |
_engine | |
.AddReference( Environment | |
.CurrentDirectory + "\\WebDriver.dll"); | |
_engine | |
.AddReference( Environment | |
.CurrentDirectory + "\\WebDriver.Support.dll"); | |
_engine.ImportNamespace("System"); | |
_engine.ImportNamespace("OpenQA.Selenium"); | |
_engine.ImportNamespace("WebScriptRunner"); | |
_engine.ImportNamespace("WebScriptRunner.Core"); | |
} | |
public WebInteractionResult Execute(string code) | |
{ | |
var result = new WebInteractionResult(); | |
var session = _engine.CreateSession(result); | |
var submission = session.CompileSubmission<object>(code); | |
var execution = submission.Execute(); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment