private void compile_button_Click(object sender, EventArgs e) { CodeDomProvider provider = GetCurrentProvider(); String sourceFile; // Build the source file name with the appropriate language extension. if (provider.FileExtension[0] == '.') { sourceFile = "TestGraph" + provider.FileExtension; } else { sourceFile = "TestGraph." + provider.FileExtension; } CompilerResults cr = CodeDomExample.CompileCode(provider, // Compile the source file into an executable output file. sourceFile, "TestGraph.exe"); if (cr.Errors.Count > 0) { textBox1.Text = "Errors encountered while building " + // Display compilation errors. sourceFile + " into " + cr.PathToAssembly + ": \r\n\n"; foreach (CompilerError ce in cr.Errors) { textBox1.AppendText(ce.ToString() + "\r\n"); } run_button.Enabled = false; } else { textBox1.Text = "Source " + sourceFile + " built into " + cr.PathToAssembly + " with no errors."; run_button.Enabled = true; } }
private void generate_button_Click(object sender, EventArgs e) { CodeDomProvider provider = GetCurrentProvider(); CodeDomExample.GenerateCode(provider, CodeDomExample.BuildHelloWorldGraph(HelloWordFrom.Text)); String sourceFile; // Build the source file name with the appropriate language extension. if (provider.FileExtension[0] == '.') { sourceFile = "TestGraph" + provider.FileExtension; } else { sourceFile = "TestGraph." + provider.FileExtension; } StreamReader sr = new StreamReader(sourceFile); // Read in the generated source file and display the source text. textBox1.Text = sr.ReadToEnd(); sr.Close(); }