static void Execute(Lazy<IUndoCommandManager> undoCommandManager, IFileTreeNodeData[] nodes) { if (!CanExecute(nodes)) return; var rsrcNodes = nodes.Cast<IResourceElementNode>().ToArray(); undoCommandManager.Value.Add(new DeleteResourceElementCommand(rsrcNodes)); }
static void Execute(Lazy<IUndoCommandManager> undoCommandManager, IFileTreeNodeData[] nodes) { if (!CanExecute(nodes)) return; if (!Method.DeleteMethodDefCommand.AskDeleteDef(dnSpy_AsmEditor_Resources.AskDeleteField)) return; var fieldNodes = nodes.Cast<IFieldNode>().ToArray(); undoCommandManager.Value.Add(new DeleteFieldDefCommand(fieldNodes)); }
static void Execute(Lazy<IUndoCommandManager> undoCommandManager, IFileTreeNodeData[] nodes) { if (!CanExecute(nodes)) return; var nsNodes = nodes.Cast<INamespaceNode>().ToArray(); undoCommandManager.Value.Add(new DeleteNamespaceCommand(nsNodes)); }
MoveNamespaceTypesToEmptypNamespaceCommand(IFileTreeNodeData[] nodes) { var nsNodes = nodes.Cast<INamespaceNode>().Where(a => a.Name != string.Empty).ToArray(); Debug.Assert(nsNodes.Length > 0); this.nodes = new DeletableNodes<INamespaceNode>(nsNodes); this.nsTarget = GetTarget(); this.typeRefInfos = RenameNamespaceCommand.GetTypeRefInfos(nodes[0].GetModule(), nsNodes); }
static void Execute(Lazy<IUndoCommandManager> undoCommandManager, IFileTreeNodeData[] nodes) { if (!CanExecute(nodes)) return; var eventNodes = nodes.Cast<IEventNode>().ToArray(); undoCommandManager.Value.Add(new DeleteEventDefCommand(eventNodes)); }
static void Execute(Lazy<IUndoCommandManager> undoCommandManager, IFileTreeNodeData[] nodes) { if (!CanExecute(nodes)) return; var propNodes = nodes.Cast<IPropertyNode>().ToArray(); undoCommandManager.Value.Add(new DeletePropertyDefCommand(propNodes)); }
ConvertAssemblyToNetModuleCommand(IFileTreeNodeData[] nodes) { this.nodes = nodes.Cast<IAssemblyFileNode>().ToArray(); }
ConvertNetModuleToAssemblyCommand(IFileTreeNodeData[] nodes) { this.nodes = nodes.Cast<IModuleFileNode>().ToArray(); this.savedStates = new SavedState[this.nodes.Length]; for (int i = 0; i < this.savedStates.Length; i++) this.savedStates[i] = new SavedState(); }
static void Execute(Lazy<IUndoCommandManager> undoCommandManager, Lazy<IDocumentSaver> documentSaver, IAppWindow appWindow, IFileTreeNodeData[] nodes) { if (!CanExecute(nodes)) return; var asmNodes = nodes.Cast<IDnSpyFileNode>().ToArray(); var files = asmNodes.SelectMany(a => a.DnSpyFile.GetAllChildrenAndSelf()); if (!documentSaver.Value.AskUserToSaveIfModified(files)) return; var keepNodes = new List<IDnSpyFileNode>(); var freeNodes = new List<IDnSpyFileNode>(); var onlyInRedoHistory = new List<IDnSpyFileNode>(); foreach (var info in GetUndoRedoInfo(undoCommandManager.Value, asmNodes)) { if (!info.IsInUndo && !info.IsInRedo) { // This asm is safe to remove freeNodes.Add(info.Node); } else if (!info.IsInUndo && info.IsInRedo) { // If we add a RemoveAssemblyCommand, the redo history will be cleared, so this // assembly will be cleared from the history and don't need to be kept. onlyInRedoHistory.Add(info.Node); } else { // The asm is in the undo history, and maybe in the redo history. We must keep it. keepNodes.Add(info.Node); } } if (keepNodes.Count > 0 || onlyInRedoHistory.Count > 0) { // We can't free the asm since older commands might reference it so we must record // it in the history. The user can click Clear History to free everything. foreach (var node in keepNodes) { foreach (var f in node.DnSpyFile.GetAllChildrenAndSelf()) { var peImage = f.PEImage; if (peImage != null) peImage.UnsafeDisableMemoryMappedIO(); } } if (keepNodes.Count != 0) undoCommandManager.Value.Add(new RemoveAssemblyCommand(appWindow.FileTreeView, keepNodes.ToArray())); else undoCommandManager.Value.ClearRedo(); // Redo history was cleared FreeAssemblies(onlyInRedoHistory); } FreeAssemblies(freeNodes); if (freeNodes.Count > 0 || onlyInRedoHistory.Count > 0) undoCommandManager.Value.CallGc(); }