static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) return; var nsNodes = nodes.Select(a => (NamespaceTreeNode)a).ToArray(); UndoCommandManager.Instance.Add(new DeleteNamespaceCommand(nsNodes)); }
internal static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) return; var propNodes = nodes.Select(a => (PropertyTreeNode)a).ToArray(); UndoCommandManager.Instance.Add(new DeletePropertyDefCommand(propNodes)); }
internal static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) return; var rsrcNodes = nodes.Select(a => (ResourceElementTreeNode)a).ToArray(); UndoCommandManager.Instance.Add(new DeleteResourceElementCommand(rsrcNodes)); }
internal static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) return; var eventNodes = nodes.Select(a => (EventTreeNode)a).ToArray(); UndoCommandManager.Instance.Add(new DeleteEventDefCommand(eventNodes)); }
internal static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) return; var asmNodes = nodes.Select(a => (AssemblyTreeNode)a).ToArray(); var modNodes = new HashSet<AssemblyTreeNode>(asmNodes); modNodes.AddRange(asmNodes.SelectMany(a => a.IsNetModule ? new AssemblyTreeNode[0] : a.Children.Cast<AssemblyTreeNode>())); if (!SaveModule.Saver.AskUserToSaveIfModified(modNodes)) return; UndoCommandManager.Instance.Add(new RemoveAssemblyCommand(asmNodes)); }
static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) return; if (!AskDeleteDef("method")) return; var methodNodes = nodes.Select(a => (MethodTreeNode)a).ToArray(); UndoCommandManager.Instance.Add(new DeleteMethodDefCommand(methodNodes)); }
static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) return; var asmNodes = nodes.Select(a => (AssemblyTreeNode)a).ToArray(); var modNodes = new HashSet<AssemblyTreeNode>(asmNodes); modNodes.AddRange(asmNodes.SelectMany(a => !a.IsAssembly ? new AssemblyTreeNode[0] : a.Children.Cast<AssemblyTreeNode>())); if (!SaveModule.Saver.AskUserToSaveIfModified(modNodes)) return; var keepNodes = new List<AssemblyTreeNode>(); var freeNodes = new List<AssemblyTreeNode>(); var onlyInRedoHistory = new List<AssemblyTreeNode>(); foreach (var info in UndoCommandManager.Instance.GetUndoRedoInfo(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) { var mod = node.DnSpyFile.ModuleDef as ModuleDefMD; if (mod != null) mod.MetaData.PEImage.UnsafeDisableMemoryMappedIO(); } UndoCommandManager.Instance.Add(new RemoveAssemblyCommand(keepNodes.ToArray())); // Redo history was cleared FreeAssemblies(onlyInRedoHistory); } FreeAssemblies(freeNodes); if (freeNodes.Count > 0 || onlyInRedoHistory.Count > 0) UndoCommandManager.Instance.CallGc(); }
ConvertNetModuleToAssemblyCommand(ILSpyTreeNode[] nodes) { this.nodes = nodes.Select(n => (AssemblyTreeNode)n).ToArray(); this.savedStates = new SavedState[this.nodes.Length]; for (int i = 0; i < this.savedStates.Length; i++) this.savedStates[i] = new SavedState(); }
ConvertAssemblyToNetModuleCommand(ILSpyTreeNode[] nodes) { this.nodes = nodes.Select(n => (AssemblyTreeNode)n).ToArray(); }
internal static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) return; if (!Method.DeleteMethodDefCommand.AskDeleteDef("field")) return; var fieldNodes = nodes.Select(a => (FieldTreeNode)a).ToArray(); UndoCommandManager.Instance.Add(new DeleteFieldDefCommand(fieldNodes)); }