static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) return; var ownerNode = nodes[0]; if (!(ownerNode is TypeTreeNode)) ownerNode = (ILSpyTreeNode)ownerNode.Parent; var typeNode = ownerNode as TypeTreeNode; Debug.Assert(typeNode != null); if (typeNode == null) throw new InvalidOperationException(); var module = ILSpyTreeNode.GetModule(typeNode); Debug.Assert(module != null); if (module == null) throw new InvalidOperationException(); var options = TypeDefOptions.Create(UTF8String.Empty, TypeConstants.DEFAULT_TYPE_NAME, module.CorLibTypes.Object.TypeDefOrRef, true); var data = new TypeOptionsVM(options, module, MainWindow.Instance.CurrentLanguage, null); var win = new TypeOptionsDlg(); win.Title = "Create Nested Type"; win.DataContext = data; win.Owner = MainWindow.Instance; if (win.ShowDialog() != true) return; UndoCommandManager.Instance.Add(new CreateNestedTypeDefCommand(typeNode, data.CreateTypeDefOptions())); }
static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) return; var nsNode = ILSpyTreeNode.GetNode<NamespaceTreeNode>(nodes[0]); string ns = nsNode == null ? string.Empty : nsNode.Name; var module = ILSpyTreeNode.GetModule(nodes[0]); Debug.Assert(module != null); if (module == null) throw new InvalidOperationException(); var options = TypeDefOptions.Create(ns, TypeConstants.DEFAULT_TYPE_NAME, module.CorLibTypes.Object.TypeDefOrRef, false); var data = new TypeOptionsVM(options, module, MainWindow.Instance.CurrentLanguage, null); var win = new TypeOptionsDlg(); win.Title = "Create Type"; win.DataContext = data; win.Owner = MainWindow.Instance; if (win.ShowDialog() != true) return; UndoCommandManager.Instance.Add(new CreateTypeDefCommand(module.Types, nodes[0], data.CreateTypeDefOptions())); }