Ejemplo n.º 1
0
        private void utBtnCompile_Click(object sender, EventArgs e)
        {
            lstCompilerResults.Items.Clear();

            lstCompilerResults.Items.Add("Initializing Compiler Services..");

            var compilerSvc = new Core.CompilerServices();

            lstCompilerResults.Items.Add("Compiling..");
            var result = compilerSvc.CompileInput(rtbCode.Text);

            if (result.Errors.HasErrors)
            {
                foreach (var error in result.Errors)
                {
                    lstCompilerResults.Items.Add(error);
                }
            }
            else
            {
                lstCompilerResults.Items.Add("Compiled Successfully!");

                if (chkRunAfterCompile.Checked)
                {
                    System.Diagnostics.Process.Start(result.PathToAssembly);
                }
            }
        }
Ejemplo n.º 2
0
        public override void RunCommand(object sender)
        {
            //create compiler service
            var compilerSvc = new Core.CompilerServices();
            var customCode  = v_Code.ConvertToUserVariable(sender);

            //compile custom code
            var result = compilerSvc.CompileInput(customCode);

            //check for errors
            if (result.Errors.HasErrors)
            {
                //throw exception
                var errors = string.Join(", ", result.Errors);
                throw new Exception("Errors Occured: " + errors);
            }
            else
            {
                var arguments = v_Args.ConvertToUserVariable(sender);

                //run code, taskt will wait for the app to exit before resuming
                System.Diagnostics.Process scriptProc = new System.Diagnostics.Process();
                scriptProc.StartInfo.FileName  = result.PathToAssembly;
                scriptProc.StartInfo.Arguments = arguments;

                if (v_applyToVariableName != "")
                {
                    //redirect output
                    scriptProc.StartInfo.RedirectStandardOutput = true;
                    scriptProc.StartInfo.UseShellExecute        = false;
                }


                scriptProc.Start();

                scriptProc.WaitForExit();

                if (v_applyToVariableName != "")
                {
                    var output = scriptProc.StandardOutput.ReadToEnd();
                    output.StoreInUserVariable(sender, v_applyToVariableName);
                }


                scriptProc.Close();
            }
        }