本文整理汇总了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 ()));
}
};
}