當前位置: 首頁>>代碼示例>>C#>>正文


C# CodeTemplates.CodeTemplate類代碼示例

本文整理匯總了C#中MonoDevelop.Ide.CodeTemplates.CodeTemplate的典型用法代碼示例。如果您正苦於以下問題:C# CodeTemplate類的具體用法?C# CodeTemplate怎麽用?C# CodeTemplate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CodeTemplate類屬於MonoDevelop.Ide.CodeTemplates命名空間,在下文中一共展示了CodeTemplate類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CodeTemplateCompletionData

		public CodeTemplateCompletionData (Document doc, CodeTemplate template)
		{
			this.doc      = doc;
			this.template = template;
			this.CompletionText = "test";
			this.Icon        = template.Icon;
			this.DisplayText = template.Shortcut;
			this.Description = template.Shortcut + Environment.NewLine + GettextCatalog.GetString (template.Description);
		}
開發者ID:transformersprimeabcxyz,項目名稱:monodevelop-1,代碼行數:9,代碼來源:CodeTemplateCompletionData.cs

示例2: SaveTemplate

		public static void SaveTemplate (CodeTemplate template)
		{
			if (!Directory.Exists (TemplatePath))
				Directory.CreateDirectory (TemplatePath);
			SaveTemplate (template, Path.Combine (TemplatePath, template.Shortcut + ".template.xml"));
		}
開發者ID:yayanyang,項目名稱:monodevelop,代碼行數:6,代碼來源:CodeTemplateService.cs

示例3: GetExpansionObject

		public static ExpansionObject GetExpansionObject (CodeTemplate template)
		{
			// TODO: Add more expansion objects.
			return new ExpansionObject ();
		}
開發者ID:yayanyang,項目名稱:monodevelop,代碼行數:5,代碼來源:CodeTemplateService.cs

示例4: InsertTemplate

		public void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context)
		{
			TextEditor.InsertTemplate (template, editor, context);
		}
開發者ID:stephenoakman,項目名稱:monodevelop,代碼行數:4,代碼來源:SourceEditorView.cs

示例5: Read

		public static CodeTemplate Read (XmlReader reader)
		{
			Debug.Assert (reader.LocalName == Node);
			
			var result = new CodeTemplate ();
			
			XmlReadHelper.ReadList (reader, Node, delegate () {
				//Console.WriteLine (reader.LocalName);
				switch (reader.LocalName) {
				case HeaderNode:
					XmlReadHelper.ReadList (reader, HeaderNode, delegate () {
						switch (reader.LocalName) {
						case GroupNode:
							result.Group = reader.ReadElementContentAsString ();
							return true;
						case VersionNode:
							result.Version = reader.ReadElementContentAsString ();
							return true;
						case MimeNode:
							result.MimeType = reader.ReadElementContentAsString ();
							return true;
						case ContextNode:
							result.CodeTemplateContext = (CodeTemplateContext)Enum.Parse (typeof (CodeTemplateContext), reader.ReadElementContentAsString ());
							return true;
						case ShortcutNode:
							result.Shortcut = reader.ReadElementContentAsString ();
							return true;
						case DescriptionNode:
							result.Description = reader.ReadElementContentAsString ();
							return true;
						case TemplateTypeNode:
							result.CodeTemplateType = (CodeTemplateType)Enum.Parse (typeof (CodeTemplateType), reader.ReadElementContentAsString ());
							return true;
						}
						return false;
					});
					return true;
				case VariablesNode:
					XmlReadHelper.ReadList (reader, VariablesNode, delegate () {
						//Console.WriteLine ("var:" + reader.LocalName);
						switch (reader.LocalName) {
						case CodeTemplateVariable.Node:
							var var = CodeTemplateVariable.Read (reader);
							result.variableDecarations [var.Name] = var;
							return true;
						}
						return false;
					});
					return true;
				case CodeNode:
					result.Code = reader.ReadElementContentAsString ();
					return true;
				}
				return false;
			});
			//Console.WriteLine ("result:" + result);
			return result;
		}
開發者ID:ZZHGit,項目名稱:monodevelop,代碼行數:58,代碼來源:CodeTemplate.cs

示例6: InsertTemplate

		public void InsertTemplate (CodeTemplate template)
		{
			TextIter iter = buf.GetIterAtMark (buf.InsertMark);
			int newCaretOffset = iter.Offset;
			string word = GetWordBeforeCaret ().Trim ();
			int beginLine = iter.Line;
			int endLine = beginLine;
			if (word.Length > 0)
				newCaretOffset = DeleteWordBeforeCaret ();
			
			string leadingWhiteSpace = GetLeadingWhiteSpace (beginLine);

			int finalCaretOffset = newCaretOffset;
			
			for (int i =0; i < template.Text.Length; ++i) {
				switch (template.Text[i]) {
					case '|':
						finalCaretOffset = newCaretOffset;
						break;
					case '\r':
						break;
					case '\t':
						buf.InsertAtCursor ("\t");
						newCaretOffset++;
						break;
					case '\n':
						buf.InsertAtCursor ("\n");
						newCaretOffset++;
						endLine++;
						break;
					default:
						buf.InsertAtCursor (template.Text[i].ToString ());
						newCaretOffset++;
						break;
				}
			}
			
			if (endLine > beginLine) {
				IndentLines (beginLine+1, endLine, leadingWhiteSpace);
			}
			
			buf.PlaceCursor (buf.GetIterAtOffset (finalCaretOffset));
		}
開發者ID:transformersprimeabcxyz,項目名稱:monodevelop-1,代碼行數:43,代碼來源:SourceEditorView.cs

示例7: InsertTemplate

		public void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Gui.Document doc)
		{
			TextEditor.InsertTemplate (template, doc);
		}
開發者ID:nocache,項目名稱:monodevelop,代碼行數:4,代碼來源:SourceEditorView.cs

示例8: InsertTemplate

		TreeIter InsertTemplate (CodeTemplate template)
		{
			TreeIter iter = GetGroup (template.Group);
			return templateStore.AppendValues (iter, template, template.Shortcut, null);
		}
開發者ID:FreeBSD-DotNet,項目名稱:monodevelop,代碼行數:5,代碼來源:CodeTemplatePanel.cs

示例9: ButtonAddClicked

		void ButtonAddClicked (object sender, EventArgs e)
		{
			var newTemplate = new CodeTemplate ();
			using (var editDialog = new EditTemplateDialog (newTemplate, true)) {
				if (MessageService.ShowCustomDialog (editDialog, this.Toplevel as Gtk.Window) == (int)ResponseType.Ok) {
					InsertTemplate (newTemplate);
					templates.Add (newTemplate);
					templatesToSave.Add (newTemplate);
				}
			}
		}
開發者ID:FreeBSD-DotNet,項目名稱:monodevelop,代碼行數:11,代碼來源:CodeTemplatePanel.cs

示例10: InsertTemplate

		internal void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext context)
		{
			using (var undo = editor.OpenUndoGroup ()) {
				var result = template.InsertTemplateContents (editor, context);

				var links = result.TextLinks.Select (l => new Mono.TextEditor.TextLink (l.Name) {
					Links = l.Links.Select (s => new TextSegment (s.Offset, s.Length)).ToList (),
					IsEditable = l.IsEditable,
					IsIdentifier = l.IsIdentifier
				}).ToList ();
				var tle = new TextLinkEditMode (this, result.InsertPosition, links);
				tle.TextLinkMode = TextLinkMode.General;
				if (tle.ShouldStartTextLinkMode) {
					tle.OldMode = CurrentMode;
					tle.StartMode ();
					CurrentMode = tle;
				}
			}
		}
開發者ID:zenek-y,項目名稱:monodevelop,代碼行數:19,代碼來源:ExtensibleTextEditor.cs

示例11: InsertTemplate

		internal void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Gui.Document document)
		{
			using (var undo = Document.OpenUndoGroup ()) {
				var result = template.InsertTemplateContents (document);

				var links = result.TextLinks;
				if (PropertyService.Get ("OnTheFlyFormatting", true)) {
					var prettyPrinter = CodeFormatterService.GetFormatter (Document.MimeType);
					if (prettyPrinter != null) {
						int endOffset = result.InsertPosition + result.Code.Length;
						//						string oldText = Document.GetTextAt (result.InsertPosition, result.Code.Length);
						//						var policies = document.Project != null ? document.Project.Policies : null;
						var oldVersion = Document.Version;
						prettyPrinter.OnTheFlyFormat (document, result.InsertPosition, endOffset);
						foreach (var textLink in links) {
							for (int i = 0; i < textLink.Links.Count; i++) {
								var segment = textLink.Links [i];
								var translatedOffset = oldVersion.MoveOffsetTo (Document.Version, result.InsertPosition + segment.Offset) - result.InsertPosition;
								textLink.Links [i] = new TextSegment (translatedOffset, segment.Length);
							}
						}
					}
				}

				var tle = new TextLinkEditMode (this, result.InsertPosition, links);
				if (tle.ShouldStartTextLinkMode) {
					tle.OldMode = CurrentMode;
					tle.StartMode ();
					CurrentMode = tle;
				}
			}
		}
開發者ID:txdv,項目名稱:monodevelop,代碼行數:32,代碼來源:ExtensibleTextEditor.cs

示例12: DeleteTemplate

		public static void DeleteTemplate (CodeTemplate template)
		{
			try {
				var fileName = Path.Combine (TemplatePath, template.Shortcut + ".template.xml");
				if (File.Exists (fileName))
					File.Delete (fileName);
			} catch (Exception e) {
				LoggingService.LogError ("Error while removing template file", e);
			}
		}
開發者ID:pabloescribanoloza,項目名稱:monodevelop,代碼行數:10,代碼來源:CodeTemplateService.cs

示例13: InsertTemplate

		internal void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Gui.Document document)
		{
			Document.BeginAtomicUndo ();
			var result = template.InsertTemplateContents (document);
			var tle = new TextLinkEditMode (this, result.InsertPosition, result.TextLinks);
			
			if (PropertyService.Get ("OnTheFlyFormatting", false)) {
				var prettyPrinter = CodeFormatterService.GetFormatter (Document.MimeType);
				if (prettyPrinter != null) {
					int endOffset = result.InsertPosition + result.Code.Length;
					string oldText = Document.GetTextAt (result.InsertPosition, result.Code.Length);
					var policies = document.Project != null ? document.Project.Policies : null;
					string text = prettyPrinter.FormatText (policies, Document.Text, result.InsertPosition, endOffset);
					
					if (text != null)
						Replace (result.InsertPosition, result.Code.Length, text);
					else
						//if formatting failed, just use the unformatted text
						text = oldText;
					
					Caret.Offset = result.InsertPosition + TranslateOffset (oldText, text, Caret.Offset - result.InsertPosition);
					foreach (TextLink textLink in tle.Links) {
						foreach (ISegment segment in textLink.Links) {
							segment.Offset = TranslateOffset (oldText, text, segment.Offset);
						}
					}
				}
			}
			
			if (tle.ShouldStartTextLinkMode) {
				tle.OldMode = CurrentMode;
				tle.StartMode ();
				CurrentMode = tle;
			}
			Document.EndAtomicUndo ();
		}
開發者ID:raufbutt,項目名稱:monodevelop-old,代碼行數:36,代碼來源:ExtensibleTextEditor.cs

示例14: EditTemplateDialog

		public EditTemplateDialog (CodeTemplate template, bool isNew)
		{
			this.Build();
			this.Title = isNew ? GettextCatalog.GetString ("New template") : GettextCatalog.GetString ("Edit template");
			this.template = template;
			this.entryShortcut1.Text = template.Shortcut  ?? "";
			this.comboboxentryGroups.Entry.Text = template.Group ?? "";
			this.comboboxentryMime.Entry.Text = template.MimeType ?? "";
			this.entryDescription.Text = template.Description ?? "";
			this.textEditor.MimeType = template.MimeType;
			this.textEditor.Text = template.Code ?? "";
			
			checkbuttonExpansion.Active = (template.CodeTemplateType & CodeTemplateType.Expansion) == CodeTemplateType.Expansion;
			checkbuttonSurroundWith.Active = (template.CodeTemplateType & CodeTemplateType.SurroundsWith) == CodeTemplateType.SurroundsWith;
			
			Gtk.Widget control = textEditor;
			scrolledwindow1.Child = control;
			control.ShowAll ();
			textEditor.CaretPositionChanged += CaretPositionChanged;
			textEditor.Options = DefaultSourceEditorOptions.PlainEditor;

			var mimeTypes = new HashSet<string> ();
			var groups    = new HashSet<string> ();
			foreach (CodeTemplate ct in CodeTemplateService.Templates) {
				mimeTypes.Add (ct.MimeType);
				groups.Add (ct.Group);
			}
			comboboxentryMime.AppendText ("");
			foreach (string mime in mimeTypes) {
				comboboxentryMime.AppendText (mime);
			}
			comboboxentryGroups.AppendText ("");
			foreach (string group in groups) {
				comboboxentryGroups.AppendText (group);
			}
			textEditor.TextChanged += DocumentTextReplaced;
			this.buttonOk.Clicked += ButtonOkClicked;
			
			checkbuttonWhiteSpaces.Hide ();
			
			variablesListStore = new ListStore (typeof (string), typeof (CodeTemplateVariable));
			comboboxVariables.Model = variablesListStore;
			comboboxVariables.Changed += ComboboxVariablesChanged;
			
			variableStore = new TreeStore (typeof (string), typeof (CodeTemplateVariable), typeof (string), typeof (int));
			treeviewVariable.Model = variableStore;
			treeviewVariable.HeadersVisible = false;
			
			treeviewVariable.AppendColumn ("", new Gtk.CellRendererText (), "text", 0);
			CellRendererText nameRenderer = new CellRendererText ();
			treeviewVariable.AppendColumn ("", nameRenderer, delegate (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) {
				nameRenderer.Markup = ((string)model.GetValue (iter, 2));
			});
			
			grid = new MonoDevelop.Components.PropertyGrid.PropertyGrid ();
			grid.PropertySort = MonoDevelop.Components.PropertyGrid.PropertySort.Alphabetical;
			grid.ShowHelp = true;
			grid.ShowAll ();
			grid.ShowToolbar = false;
			
			vbox4.Remove (scrolledwindow2);
			vbox4.PackEnd (grid, true, true, 0);
			
			UpdateVariables ();
		}
開發者ID:ZZHGit,項目名稱:monodevelop,代碼行數:65,代碼來源:EditTemplateDialog.cs

示例15: InsertTemplate

		internal void InsertTemplate (CodeTemplate template, MonoDevelop.Ide.Gui.Document document)
		{
			using (var undo = Document.OpenUndoGroup ()) {
				var result = template.InsertTemplateContents (document);

				var links = result.TextLinks;

				var tle = new TextLinkEditMode (this, result.InsertPosition, links);
				tle.TextLinkMode = TextLinkMode.General;
				if (tle.ShouldStartTextLinkMode) {
					tle.OldMode = CurrentMode;
					tle.StartMode ();
					CurrentMode = tle;
				}
			}
		}
開發者ID:John-Colvin,項目名稱:monodevelop,代碼行數:16,代碼來源:ExtensibleTextEditor.cs


注:本文中的MonoDevelop.Ide.CodeTemplates.CodeTemplate類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。