当前位置: 首页>>代码示例>>C#>>正文


C# MonoDevelop.CreateCodeGenerator方法代码示例

本文整理汇总了C#中MonoDevelop.CreateCodeGenerator方法的典型用法代码示例。如果您正苦于以下问题:C# MonoDevelop.CreateCodeGenerator方法的具体用法?C# MonoDevelop.CreateCodeGenerator怎么用?C# MonoDevelop.CreateCodeGenerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MonoDevelop的用法示例。


在下文中一共展示了MonoDevelop.CreateCodeGenerator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Implement

		public static void Implement (MonoDevelop.Ide.Gui.Document document, IType abstractType)
		{
			TextEditor editor = document.Editor.Parent;
			
			DocumentLocation location = editor.Caret.Location;
			IType declaringType = document.CompilationUnit.GetTypeAt (location.Line, location.Column);
			
			InsertionCursorEditMode mode = new InsertionCursorEditMode (editor, CodeGenerationService.GetInsertionPoints (document, declaringType));
			ModeHelpWindow helpWindow = new ModeHelpWindow ();
			helpWindow.TransientFor = IdeApp.Workbench.RootWindow;
			helpWindow.TitleText = GettextCatalog.GetString ("<b>Implement abstract members -- Targeting</b>");
			helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Key</b>"), GettextCatalog.GetString ("<b>Behavior</b>")));
			helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Up</b>"), GettextCatalog.GetString ("Move to <b>previous</b> target point.")));
			helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Down</b>"), GettextCatalog.GetString ("Move to <b>next</b> target point.")));
			helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Enter</b>"), GettextCatalog.GetString ("<b>Declare interface implementation</b> at target point.")));
			helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Esc</b>"), GettextCatalog.GetString ("<b>Cancel</b> this refactoring.")));
			mode.HelpWindow = helpWindow;
			mode.CurIndex = mode.InsertionPoints.Count - 1;
			mode.StartMode ();
			mode.Exited += delegate(object s, InsertionCursorEventArgs args) {
				if (args.Success) {
					CodeGenerator generator = document.CreateCodeGenerator ();
					var missingAbstractMembers = abstractType.Members.Where (member => member.IsAbstract && !member.IsSpecialName && !declaringType.Members.Any (m => member.Name == m.Name));
					StringBuilder sb = new StringBuilder ();
					foreach (var member in missingAbstractMembers) {
						if (sb.Length > 0) {
							sb.Append (editor.EolMarker);
							sb.Append (editor.EolMarker);
						}
				
						sb.Append (generator.CreateMemberImplementation (declaringType, member, false).Code);
					}
					args.InsertionPoint.Insert (document.Editor, generator.WrapInRegions ("implemented abstract members of " + abstractType.FullName, sb.ToString ()));
				}
			};
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:36,代码来源:ImplementAbstractMembers.cs


注:本文中的MonoDevelop.CreateCodeGenerator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。