示例#1
0
        static void Execute(Lazy <IUndoCommandManager> undoCommandManager, IAppWindow appWindow, IFileTreeNodeData[] nodes)
        {
            if (!CanExecute(nodes))
            {
                return;
            }

            var    nsNode = nodes[0].GetAncestorOrSelf <INamespaceNode>();
            string ns     = nsNode?.Name ?? string.Empty;

            var module = nodes[0].GetModule();

            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, appWindow.LanguageManager, null);
            var win  = new TypeOptionsDlg();

            win.Title       = dnSpy_AsmEditor_Resources.CreateTypeCommand2;
            win.DataContext = data;
            win.Owner       = appWindow.MainWindow;
            if (win.ShowDialog() != true)
            {
                return;
            }

            var cmd = new CreateTypeDefCommand(module.Types, nodes[0], data.CreateTypeDefOptions());

            undoCommandManager.Value.Add(cmd);
            appWindow.FileTabManager.FollowReference(cmd.typeNode);
        }
示例#2
0
        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       = CMD_NAME;
            win.DataContext = data;
            win.Owner       = MainWindow.Instance;
            if (win.ShowDialog() != true)
            {
                return;
            }

            var cmd = new CreateTypeDefCommand(module.Types, nodes[0], data.CreateTypeDefOptions());

            UndoCommandManager.Instance.Add(cmd);
            MainWindow.Instance.JumpToReference(cmd.typeNode);
        }
示例#3
0
		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 = CMD_NAME;
			win.DataContext = data;
			win.Owner = MainWindow.Instance;
			if (win.ShowDialog() != true)
				return;

			var cmd = new CreateTypeDefCommand(module.Types, nodes[0], data.CreateTypeDefOptions());
			UndoCommandManager.Instance.Add(cmd);
			MainWindow.Instance.JumpToReference(cmd.typeNode);
		}
示例#4
0
 public override void Execute(AsmEditorContext context) => CreateTypeDefCommand.Execute(undoCommandManager, appWindow, context.Nodes);
示例#5
0
 public override bool IsVisible(AsmEditorContext context) => CreateTypeDefCommand.CanExecute(context.Nodes);
示例#6
0
 public override void Execute(AsmEditorContext context) => CreateTypeDefCommand.Execute(undoCommandService, appService, context.Nodes);
示例#7
0
 protected override void ExecuteInternal(ILSpyTreeNode[] nodes)
 {
     CreateTypeDefCommand.Execute(nodes);
 }
示例#8
0
 protected override bool CanExecuteInternal(ILSpyTreeNode[] nodes)
 {
     return(CreateTypeDefCommand.CanExecute(nodes));
 }
示例#9
0
		static void Execute(Lazy<IUndoCommandManager> undoCommandManager, IAppWindow appWindow, IFileTreeNodeData[] nodes) {
			if (!CanExecute(nodes))
				return;

			var nsNode = nodes[0].GetAncestorOrSelf<INamespaceNode>();
			string ns = nsNode == null ? string.Empty : nsNode.Name;

			var module = nodes[0].GetModule();
			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, appWindow.LanguageManager, null);
			var win = new TypeOptionsDlg();
			win.Title = dnSpy_AsmEditor_Resources.CreateTypeCommand2;
			win.DataContext = data;
			win.Owner = appWindow.MainWindow;
			if (win.ShowDialog() != true)
				return;

			var cmd = new CreateTypeDefCommand(module.Types, nodes[0], data.CreateTypeDefOptions());
			undoCommandManager.Value.Add(cmd);
			appWindow.FileTabManager.FollowReference(cmd.typeNode);
		}