internal CompiledExe(ProcessStartInfo pInfo, ErrorListing errors) { Errors = errors; this.ProcessInfo = pInfo; }
internal CompiledAssembly(Assembly ass, ErrorListing errors) { Errors = errors; this.Assembly = ass; }
private static ICompliedResult Compile( ) { ICodeCompiler compiler = null; if (CodeType == CodeType.CSharp) { compiler = new CSharpCodeProvider().CreateCompiler(); } else if (CodeType == CodeType.VisualBasic) { compiler = new VBCodeProvider().CreateCompiler(); } #region CompilerParameters CompilerParameters parameters = new CompilerParameters(); parameters.GenerateInMemory = RunInMemory; parameters.GenerateExecutable = IsGenerateEXE; if (MainClass.Trim() != "") { parameters.MainClass = MainClass; } if (!RunInMemory) { parameters.OutputAssembly = OutputFile; } if (References == null) { foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { parameters.ReferencedAssemblies.Add(asm.Location); } } else { foreach (string assemblyName in References) { parameters.ReferencedAssemblies.Add(assemblyName); } } #endregion Results = compiler.CompileAssemblyFromSource(parameters, SourceCode); string[] err = new string[Results.Errors.Count]; for (int i = 0; i < err.Length; i++) { err[i] = Results.Errors[i].ErrorText + "(" + Results.Errors[i].ErrorNumber + "). In File: " + Results.Errors[i].FileName + ". On Line: " + Results.Errors[i].Line.ToString() + ". Column: " + Results.Errors[i].Column.ToString(); } Errors = new ErrorListing(err); // Check error count if (Results.Errors.Count == 0) { if (IsGenerateEXE) { #region Run EXE string cmdLine = null; if (CommandParams != null) { foreach (string cmd in CommandParams) { cmdLine += cmd + " "; } } return(new CompiledExe(new ProcessStartInfo(OutputFile, cmdLine), Errors)); #endregion } else { return(new CompiledAssembly(Results.CompiledAssembly, Errors)); } } else { if (IsGenerateEXE) { return(new CompiledExe(null, Errors)); } else { return(new CompiledAssembly(null, Errors)); } } return(null); }