monocompiler.cs

来自「SharpDevelop2.0.0 c#开发免费工具」· CS 代码 · 共 54 行

CS
54
字号
// <file>
//     <copyright see="prj:///doc/copyright.txt"/>
//     <license see="prj:///doc/license.txt"/>
//     <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
//     <version>$Revision: 915 $</version>
// </file>

using System;
using System.CodeDom.Compiler;
using System.IO;

namespace ICSharpCode.Build.Tasks
{
	public class MonoCompiler
	{
		CompilerResults results;
		
		public MonoCompiler()
		{
		}
		
		public int Run(string compiler, string args, ICompilerResultsParser parser)
		{
			string responseFileName = Path.GetTempFileName();
			
			using (StreamWriter writer = new StreamWriter(responseFileName)) {
				writer.Write(args);
			}
		
			//string outstr = String.Concat(compilerFileName, compilerparameters.NoConfig ? " /noconfig" : String.Empty, " \"@", responseFileName, "\"");
			string outputFileName = String.Empty;
			string errorFileName  = String.Empty;
			TempFileCollection tempFiles = new TempFileCollection();
			string command = String.Concat(compiler, " \"@", responseFileName, "\"");
			
			int returnValue = Executor.ExecWaitWithCapture(command, tempFiles, ref outputFileName, ref errorFileName);
			
			results = parser.Parse(tempFiles, errorFileName);
			
			File.Delete(responseFileName);
			File.Delete(outputFileName);
			File.Delete(errorFileName);
			
			return returnValue;
		}
		
		public CompilerResults Results {
			get {
				return results;
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?