static void Execute(Lazy<IUndoCommandService> undoCommandService, DocumentTreeNodeData[] nodes) { if (!CanExecute(nodes)) return; var eventNodes = nodes.Cast<EventNode>().ToArray(); undoCommandService.Value.Add(new DeleteEventDefCommand(eventNodes)); }
internal static void Execute(Lazy<IUndoCommandService> undoCommandService, Lazy<IDocumentSaver> documentSaver, IAppService appService, DocumentTreeNodeData[] nodes) { if (!CanExecute(nodes)) return; var asmNodes = nodes.Cast<DsDocumentNode>().ToArray(); var files = asmNodes.SelectMany(a => a.Document.GetAllChildrenAndSelf()); if (!documentSaver.Value.AskUserToSaveIfModified(files)) return; var keepNodes = new List<DsDocumentNode>(); var freeNodes = new List<DsDocumentNode>(); var onlyInRedoHistory = new List<DsDocumentNode>(); foreach (var info in GetUndoRedoInfo(undoCommandService.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.Document.GetAllChildrenAndSelf()) MemoryMappedIOHelper.DisableMemoryMappedIO(f); } if (keepNodes.Count != 0) undoCommandService.Value.Add(new RemoveAssemblyCommand(appService.DocumentTreeView, keepNodes.ToArray())); else undoCommandService.Value.ClearRedo(); // Redo history was cleared FreeAssemblies(onlyInRedoHistory); } FreeAssemblies(freeNodes); if (freeNodes.Count > 0 || onlyInRedoHistory.Count > 0) undoCommandService.Value.CallGc(); }
static void Execute(Lazy<IUndoCommandService> undoCommandService, DocumentTreeNodeData[] nodes) { if (!CanExecute(nodes)) return; if (!AskDeleteDef(dnSpy_AsmEditor_Resources.AskDeleteMethod)) return; var methodNodes = nodes.Cast<MethodNode>().ToArray(); undoCommandService.Value.Add(new DeleteMethodDefCommand(methodNodes)); }
static void Execute(Lazy<IUndoCommandService> undoCommandService, DocumentTreeNodeData[] nodes) { if (!CanExecute(nodes)) return; var rsrcNodes = nodes.Cast<ResourceElementNode>().ToArray(); undoCommandService.Value.Add(new DeleteResourceElementCommand(rsrcNodes)); }
static void Execute(Lazy<IUndoCommandService> undoCommandService, DocumentTreeNodeData[] nodes) { if (!CanExecute(nodes)) return; var nsNodes = nodes.Cast<NamespaceNode>().ToArray(); undoCommandService.Value.Add(new DeleteNamespaceCommand(nsNodes)); }
MoveNamespaceTypesToEmptypNamespaceCommand(DocumentTreeNodeData[] nodes) { var nsNodes = nodes.Cast<NamespaceNode>().Where(a => a.Name != string.Empty).ToArray(); Debug.Assert(nsNodes.Length > 0); this.nodes = new DeletableNodes<NamespaceNode>(nsNodes); nsTarget = GetTarget(); typeRefInfos = RenameNamespaceCommand.GetTypeRefInfos(nodes[0].GetModule(), nsNodes); }
ConvertAssemblyToNetModuleCommand(DocumentTreeNodeData[] nodes) { this.nodes = nodes.Cast<AssemblyDocumentNode>().ToArray(); }
ConvertNetModuleToAssemblyCommand(DocumentTreeNodeData[] nodes) { this.nodes = nodes.Cast<ModuleDocumentNode>().ToArray(); savedStates = new SavedState[this.nodes.Length]; for (int i = 0; i < savedStates.Length; i++) savedStates[i] = new SavedState(); }