Last active
May 11, 2020 14:47
-
-
Save MikeCodesDotNET/da64a67a7795ded857d8782b448bdbe4 to your computer and use it in GitHub Desktop.
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 Script userScript; | |
private void CompileScript() | |
{ | |
UpdateSource(); //Handles creating a copy of the script which includes variables the user never sees. | |
string text = csSource.Text; //csSource is an object from the UI provider | |
userScript = CSharpScript.Create(text, options: userScriptOptions); | |
userScript.Compile(); | |
//Validation class | |
ScriptValidator scriptValidator = new ScriptValidator(userScript); | |
if(!scriptValidator.IsValid) | |
{ | |
MessageBox.Show($"Found {scriptValidator.Errors.Count()} illegal APIs in script.", "Build Error"); | |
userScript = null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment