⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compilerparameters.cs

📁 CSharpDevelop:这是一个包含源代码的C#、VB.NET的编辑器。
💻 CS
字号:
// CSProject.cs
// Copyright (C) 2001 Mike Krueger
// 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

using System;
using System.Xml;
using System.Diagnostics;

namespace CSDefinition {
	
	public enum CompileTarget {
		Exe, 
		WinExe, 
		Library
	};	
	
	/// <summary>
	/// This class handles general compiler parameters, it it used for default compiler parameters
	/// and for project compiler parameters
	/// </summary>
	public class CSCompilerParameters
	{
		int  warninglevel       = 4;
		bool runwithwarnings    = false;
		bool pauseconsoleoutput = true;
		bool debugmode          = true;
		bool optimize           = true;
		bool unsafecode         = false;
		
		public int WarningLevel {
			get {
				return warninglevel;
			}
			set {
				warninglevel = value;
			}
		}
		
		public bool RunWithWarnings {
			get {
				return runwithwarnings;
			}
			set {
				runwithwarnings = value;
			}
		}
		
		public bool PauseConsoleOutput {
			get {
				return pauseconsoleoutput;
			}
			set {
				pauseconsoleoutput = value;
			}
		}
		
		public bool Debugmode {
			get {
				return debugmode;
			}
			set {
				debugmode = value;
			}
		}
		
		public bool Optimize {
			get {
				return optimize;
			}
			set {
				optimize = value;
			}
		}
		
		public bool UnsafeCode {
			get {
				return unsafecode;
			}
			set {
				unsafecode = value;
			}
		}
		
		public CSCompilerParameters()
		{
		}
		
		public CSCompilerParameters(XmlElement element)
		{
			warninglevel     = Int32.Parse(element["WARNINGLEVEL"].InnerText);
			runwithwarnings  = Boolean.Parse(element["RUNWITHWARNINGS"].InnerText);
			debugmode        = Boolean.Parse(element["DEBUGMODE"].InnerText);
			optimize         = Boolean.Parse(element["OPTIMIZE"].InnerText);
			unsafecode       = Boolean.Parse(element["UNSAFE"].InnerText);
			pauseconsoleoutput = Boolean.Parse(element["CONSOLEPAUSE"].InnerText);
		}
		
		public virtual object FromXmlElement(XmlElement element)
		{
			return new CSCompilerParameters(element);
		}
		
		public virtual XmlElement ToXmlElement(XmlDocument doc)
		{
			if (doc == null)
				throw new ArgumentNullException("CompilerParameters.ToXmlElement(XmlDocument doc) : doc can't be null");
			
			XmlElement element = doc.CreateElement("COMPILERPARAMETERS");
			
			XmlElement sub = doc.CreateElement("WARNINGLEVEL");
			sub.InnerText = warninglevel.ToString();
			element.AppendChild(sub);
			
			sub = doc.CreateElement("RUNWITHWARNINGS");
			sub.InnerText = runwithwarnings.ToString();
			element.AppendChild(sub);
			
			sub = doc.CreateElement("DEBUGMODE");
			sub.InnerText = debugmode.ToString();
			element.AppendChild(sub);
			
			sub = doc.CreateElement("OPTIMIZE");
			sub.InnerText = optimize.ToString();
			element.AppendChild(sub);
			
			sub = doc.CreateElement("UNSAFE");
			sub.InnerText = unsafecode.ToString();
			element.AppendChild(sub);
			
			sub = doc.CreateElement("CONSOLEPAUSE");
			sub.InnerText = pauseconsoleoutput.ToString();
			element.AppendChild(sub);
			
			return element;
		}
	}
	
	/// <summary>
	/// This class handles project specific compiler parameters
	/// </summary>
	public class CSProjectCompilerParameters : CSCompilerParameters
	{
		string         mainclass     = null;
		CompileTarget  compiletarget = CompileTarget.Exe;
		
		public string MainClass {
			get {
				return mainclass;
			}
			set {
				mainclass = value;
			}
		}
		
		public CompileTarget CompileTarget {
			get {
				return compiletarget;
			}
			set {
				compiletarget = value;
			}
		}
		
		public CSProjectCompilerParameters()
		{
		}
		public CSProjectCompilerParameters(XmlElement element) : base(element)
		{
			mainclass     = element["MAINCLASS"].InnerText;
			compiletarget = (CompileTarget)Enum.Parse(typeof(CompileTarget), element["TARGET"].InnerText);
		}
		
		public override object FromXmlElement(XmlElement element)
		{
			return new CSProjectCompilerParameters(element);
		}
		
		public override XmlElement ToXmlElement(XmlDocument doc)
		{
			XmlElement element = base.ToXmlElement(doc);
			
			XmlElement sub = doc.CreateElement("MAINCLASS");
			sub.InnerText = mainclass;
			element.AppendChild(sub);
			
			sub = doc.CreateElement("TARGET");
			sub.InnerText = compiletarget.ToString();
			element.AppendChild(sub);
			return element;
		}
	}
}

⌨️ 快捷键说明

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