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

📄 codetemplate.cs

📁 SharpDevelop2.0.0 c#开发免费工具
💻 CS
字号:
// <file>
//     <copyright see="prj:///doc/copyright.txt"/>
//     <license see="prj:///doc/license.txt"/>
//     <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
//     <version>$Revision: 915 $</version>
// </file>

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

namespace ICSharpCode.SharpDevelop.Internal.Templates
{
	/// <summary>
	/// This class reperesents a single Code Template
	/// </summary>
	public class CodeTemplate
	{
		string shortcut     = String.Empty;
		string description  = String.Empty;
		string text         = String.Empty;
		
		public string Shortcut {
			get {
				return shortcut;
			}
			set {
				shortcut = value;
				System.Diagnostics.Debug.Assert(shortcut != null, "ICSharpCode.SharpDevelop.Internal.Template : string Shortcut == null");
			}
		}
		
		public string Description {
			get {
				return description;
			}
			set {
				description = value;
				System.Diagnostics.Debug.Assert(description != null, "ICSharpCode.SharpDevelop.Internal.Template : string Description == null");
			}
		}
		
		public string Text {
			get {
				return text;
			}
			set {
				text = value;
				System.Diagnostics.Debug.Assert(text != null, "ICSharpCode.SharpDevelop.Internal.Template : string Text == null");
			}
		}
		
		public CodeTemplate()
		{
		}
		
		public CodeTemplate(string shortcut, string description, string text)
		{
			this.shortcut    = shortcut;
			this.description = description;
			this.text        = text;
		}
		
		public CodeTemplate(XmlElement el)
		{
			if (el == null) {
				throw new ArgumentNullException("el");
			}
			
			if (el.Attributes["template"] == null || el.Attributes["description"] == null) {
				throw new Exception("CodeTemplate(XmlElement el) : template and description attributes must exist (check the CodeTemplate XML)");
			}
			
			Shortcut    = el.GetAttribute("template");
			Description = el.GetAttribute("description");
			Text        = el.InnerText;
		}
		
		public XmlElement ToXmlElement(XmlDocument doc)
		{
			if (doc == null) {
				throw new ArgumentNullException("doc");
			}
			
			XmlElement newElement = doc.CreateElement("CodeTemplate");
			newElement.SetAttribute("template",    Shortcut);
			newElement.SetAttribute("description", Description);
			newElement.InnerText = Text;
			return newElement;
		}
	}
}

⌨️ 快捷键说明

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