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

📄 addinoptions.cs

📁 c#源代码
💻 CS
字号:
//
// SharpDevelop NAnt add-in.
//
// Copyright (C) 2004 Matthew Ward
//
// 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
//
// Matthew Ward (mrward@users.sourceforge.net)

using ICSharpCode.Core.Properties;
using ICSharpCode.Core.Services;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;

namespace ICSharpCode.NAntAddIn
{
	/// <summary>
	/// The NAnt add-in options.
	/// </summary>
	public class AddInOptions
	{
		public static readonly string OptionsProperty = "NAntAddIn.Options";

		#region Property names
		public static readonly string NAntVersionProperty = "NAntVersion";
		public static readonly string NAntFileNameProperty = "NAntFileName";
		public static readonly string NAntArgumentsProperty = "NAntArguments";
		public static readonly string VerboseProperty = "Verbose";
		public static readonly string ShowLogoProperty = "ShowLogo";
		public static readonly string QuietProperty = "Quiet";
		public static readonly string DebugModeProperty = "DebugMode";
		#endregion
		
		#region Property defaults	
		public static readonly string DefaultNAntVersion = "0.84";
		public static readonly string DefaultNAntFileName = "nant.exe";
		#endregion
		
		static IProperties properties;

		static AddInOptions()
 		{
			PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
			properties = (IProperties)propertyService.GetProperty(OptionsProperty, new DefaultProperties());
		}

 		static IProperties Properties {
			get {
				Debug.Assert(properties != null);
				return properties;
 			}
		}

		#region Properties

		/// <summary>
		/// Gets the NAnt version that the add-in is currently supporting.
		/// </summary>
		public static string NAntVersion
		{
			get {
				return (string)Properties.GetProperty(NAntVersionProperty, DefaultNAntVersion);
			}
			
			set {
				Properties.SetProperty(NAntVersionProperty, value);
			}
		}
		
		/// <summary>
		/// Gets the NAnt executable filename.  
		/// </summary>
		/// <remarks>
		/// This is either the full filename including path
		/// or just the name of the executable (nant.exe) in which
		/// case it is assumed that NAnt is on the path.
		/// </remarks>
		public static string NAntFileName
		{
			get {
				return (string)Properties.GetProperty(NAntFileNameProperty, GetDefaultNAntFileName());
			}
			
			set {
				Properties.SetProperty(NAntFileNameProperty, value);
			}
		}
		
		/// <summary>
		/// Gets the NAnt command line arguments.
		/// </summary>
		public static string NAntArguments
		{
			get {
				return (string)Properties.GetProperty(NAntArgumentsProperty, String.Empty);
			}
			
			set {
				Properties.SetProperty(NAntArgumentsProperty, value);
			}
		}		
		
		/// <summary>
		/// Gets the NAnt -verbose setting.
		/// </summary>
		public static bool Verbose
		{
			get {
				return (bool)Properties.GetProperty(VerboseProperty, false);
			}
			
			set {
				Properties.SetProperty(VerboseProperty, value);
			}
		}	
		
		/// <summary>
		/// Gets the NAnt show logo setting.
		/// </summary>
		public static bool ShowLogo
		{
			get {
				return (bool)Properties.GetProperty(ShowLogoProperty, false);
			}
			
			set {
				Properties.SetProperty(ShowLogoProperty, value);
			}
		}
		
		/// <summary>
		/// Gets the NAnt -quiet setting.
		/// </summary>
		public static bool Quiet
		{
			get {
				return (bool)Properties.GetProperty(QuietProperty, false);
			}
			
			set {
				Properties.SetProperty(QuietProperty, value);
			}
		}		
		
		/// <summary>
		/// Gets the NAnt -debug setting.
		/// </summary>
		public static bool DebugMode
		{
			get {
				return (bool)Properties.GetProperty(DebugModeProperty, false);
			}
			
			set {
				Properties.SetProperty(DebugModeProperty, value);
			}
		}
		
		#endregion
		
		public static string[] GetSupportedNAntVersions()
		{
			return new string[] { "0.84", "0.85" };
		}
		
		/// <summary>
		/// Gets the stylesheet that will be used to convert
		/// the SharpDevelop project file ".prjx" to a NAnt 
		/// build file ".build".</summary>
		public static string StylesheetFileName	{
			get {
				return GetStylesheetFileName(NAntVersion);
			}
		}
		
		static string GetStylesheetFileName(string version)
		{
			return String.Concat(version, Path.DirectorySeparatorChar, "SharpDevelopProjectToNant.xsl");
		}
		
		/// <summary>
		/// Gets the default NAnt filename property.
		/// </summary>
		/// <remarks>
		/// If the NAnt filename property does not exist the add-in works out
		/// where the nant.exe is that is shipped with SharpDevelop.  If the 
		/// property already exists then the <see cref="DefaultNAntFilename"/>.
		/// </remarks>
		/// <returns>The NAnt filename.</returns>
		static string GetDefaultNAntFileName()
		{
			string defaultFileName = DefaultNAntFileName;
			
			if (Properties.GetProperty(NAntFileNameProperty) == null) {
				Assembly sharpDevelopAssembly = Assembly.GetEntryAssembly();
				
				string sharpDevelopDirectory = Path.GetDirectoryName(sharpDevelopAssembly.CodeBase.Replace("file:///", String.Empty));
							
				defaultFileName = Path.Combine(sharpDevelopDirectory, String.Concat("nant", Path.DirectorySeparatorChar, "nant.exe"));
			}
				
			return defaultFileName;			
		}
		
	}
}

⌨️ 快捷键说明

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