/// <summary> Compiles the specified source code. </summary> /// <param name="text">The text.</param> /// <param name="language">The language.</param> /// <returns>A result from the compilation</returns> public static CompileResult Compile(string text, ScriptLanguage language) { Scripting engine = language == ScriptLanguage.VB ? Scripting.VB : Scripting.CS; CompilerParameters args = new CompilerParameters(); args.GenerateInMemory = true; CompilerResults results = engine.CompileSource(text, args); if (results.Errors.HasErrors) { return(new CompileResult(null, results.Errors)); } List <Command> list = Scripting.LoadFrom(results.CompiledAssembly); return(new CompileResult(list.ToArray(), null)); }