示例#1
0
		public SnippetElement GetElement(SnippetInfo snippetInfo)
		{
			if ("refactoring:propall".Equals(snippetInfo.Tag, StringComparison.OrdinalIgnoreCase))
				return new InlineRefactorSnippetElement(context => CreateDialog(context), "{" + snippetInfo.Tag + "}");
			
			return null;
		}
		public SnippetElement GetElement(SnippetInfo snippetInfo)
		{
			int typeSeparator = snippetInfo.Tag.IndexOf(':');
			
			if (typeSeparator > 0) {
				string type = snippetInfo.Tag.Substring(0, typeSeparator);
				string name = snippetInfo.Tag.Substring(typeSeparator + 1);
				
				if ("anchor".Equals(type, StringComparison.OrdinalIgnoreCase))
					return new SnippetAnchorElement(name);
			}
			
			return null;
		}
		public SnippetElement GetElement(SnippetInfo snippetInfo)
		{
			if ("Selection".Equals(snippetInfo.Tag, StringComparison.OrdinalIgnoreCase))
				return new SnippetSelectionElement() { Indentation = GetWhitespaceBefore(snippetInfo.SnippetText, snippetInfo.Position).Length };
			if ("Caret".Equals(snippetInfo.Tag, StringComparison.OrdinalIgnoreCase)) {
				// If a ${Selection} exists, use the ${Caret} only if there is text selected
				// (if no text is selected, ${Selection} will set the caret
				if (snippetInfo.SnippetText.IndexOf("${Selection}", StringComparison.OrdinalIgnoreCase) >= 0)
					return new SnippetCaretElement(setCaretOnlyIfTextIsSelected: true);
				else
					return new SnippetCaretElement();
			}
			
			return null;
		}