static void Execute(Lazy <IUndoCommandService> undoCommandService, IAppService appService, DocumentTreeNodeData[] nodes) { if (!AddNetModuleToAssemblyCommand.CanExecute(nodes)) { return; } var dialog = new System.Windows.Forms.OpenFileDialog() { Filter = PickFilenameConstants.NetModuleFilter, RestoreDirectory = true, }; if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } if (string.IsNullOrEmpty(dialog.FileName)) { return; } var fm = appService.DocumentTreeView.DocumentService; var file = fm.CreateDocument(DsDocumentInfo.CreateDocument(dialog.FileName), dialog.FileName, true); if (file.ModuleDef == null || file.AssemblyDef != null || !(file is IDsDotNetDocument)) { MsgBox.Instance.Show(string.Format(dnSpy_AsmEditor_Resources.Error_NotNetModule, file.Filename), MsgBoxButton.OK); var id = file as IDisposable; if (id != null) { id.Dispose(); } return; } var node = (DsDocumentNode)nodes[0]; var newModNode = node.Context.DocumentTreeView.CreateModule((IDsDotNetDocument)file); var cmd = new AddExistingNetModuleToAssemblyCommand(undoCommandService.Value, node, newModNode); undoCommandService.Value.Add(cmd); appService.DocumentTabService.FollowReference(cmd.modNode); }
static void Execute(Lazy <IUndoCommandManager> undoCommandManager, IAppWindow appWindow, IFileTreeNodeData[] nodes) { if (!AddNetModuleToAssemblyCommand.CanExecute(nodes)) { return; } var dialog = new System.Windows.Forms.OpenFileDialog() { Filter = PickFilenameConstants.NetModuleFilter, RestoreDirectory = true, }; if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } if (string.IsNullOrEmpty(dialog.FileName)) { return; } var fm = appWindow.FileTreeView.FileManager; var file = DnSpyFile.CreateDnSpyFileFromFile(DnSpyFileInfo.CreateFile(dialog.FileName), dialog.FileName, fm.Settings.UseMemoryMappedIO, fm.Settings.LoadPDBFiles, fm.AssemblyResolver, true); if (file.ModuleDef == null || file.AssemblyDef != null || !(file is IDnSpyDotNetFile)) { Shared.App.MsgBox.Instance.Show(string.Format(dnSpy_AsmEditor_Resources.Error_NotNetModule, file.Filename), MsgBoxButton.OK); var id = file as IDisposable; if (id != null) { id.Dispose(); } return; } var node = (IDnSpyFileNode)nodes[0]; var newModNode = node.Context.FileTreeView.CreateModule((IDnSpyDotNetFile)file); var cmd = new AddExistingNetModuleToAssemblyCommand(undoCommandManager.Value, node, newModNode); undoCommandManager.Value.Add(cmd); appWindow.FileTabManager.FollowReference(cmd.modNode); }
static void Execute(ILSpyTreeNode[] nodes) { if (!AddNetModuleToAssemblyCommand.CanExecute(nodes)) { return; } var dialog = new System.Windows.Forms.OpenFileDialog() { Filter = ".NET NetModules (*.netmodule)|*.netmodule|All files (*.*)|*.*", RestoreDirectory = true, }; if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } if (string.IsNullOrEmpty(dialog.FileName)) { return; } var asm = new LoadedAssembly(MainWindow.Instance.CurrentAssemblyList, dialog.FileName); if (asm.ModuleDefinition == null || asm.AssemblyDefinition != null) { MainWindow.Instance.ShowMessageBox(string.Format("{0} is not a NetModule", asm.FileName), System.Windows.MessageBoxButton.OK); asm.TheLoadedFile.Dispose(); return; } var cmd = new AddExistingNetModuleToAssemblyCommand((AssemblyTreeNode)nodes[0], asm); UndoCommandManager.Instance.Add(cmd); MainWindow.Instance.JumpToReference(cmd.modNode); }
static void Execute(ILSpyTreeNode[] nodes) { if (!AddNetModuleToAssemblyCommand.CanExecute(nodes)) { return; } var dialog = new System.Windows.Forms.OpenFileDialog() { Filter = PickFilenameConstants.NetModuleFilter, RestoreDirectory = true, }; if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } if (string.IsNullOrEmpty(dialog.FileName)) { return; } var asm = MainWindow.Instance.DnSpyFileList.CreateDnSpyFile(dialog.FileName); if (asm.ModuleDef == null || asm.AssemblyDef != null) { MainWindow.Instance.ShowMessageBox(string.Format("{0} is not a NetModule", asm.Filename), System.Windows.MessageBoxButton.OK); asm.Dispose(); return; } var cmd = new AddExistingNetModuleToAssemblyCommand((AssemblyTreeNode)nodes[0], asm); UndoCommandManager.Instance.Add(cmd); MainWindow.Instance.JumpToReference(cmd.modNode); }
public override void Execute(AsmEditorContext context) => AddExistingNetModuleToAssemblyCommand.Execute(undoCommandService, appService, context.Nodes);
public override bool IsVisible(AsmEditorContext context) => AddExistingNetModuleToAssemblyCommand.CanExecute(context.Nodes);
public override void Execute(AsmEditorContext context) { AddExistingNetModuleToAssemblyCommand.Execute(undoCommandManager, appWindow, context.Nodes); }
static void Execute(ILSpyTreeNode[] nodes) { if (!AddNetModuleToAssemblyCommand.CanExecute(nodes)) return; var dialog = new System.Windows.Forms.OpenFileDialog() { Filter = ".NET NetModules (*.netmodule)|*.netmodule|All files (*.*)|*.*", RestoreDirectory = true, }; if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; if (string.IsNullOrEmpty(dialog.FileName)) return; var asm = new LoadedAssembly(MainWindow.Instance.CurrentAssemblyList, dialog.FileName); if (asm.ModuleDefinition == null || asm.AssemblyDefinition != null) { MainWindow.Instance.ShowMessageBox(string.Format("{0} is not a NetModule", asm.FileName), System.Windows.MessageBoxButton.OK); asm.TheLoadedFile.Dispose(); return; } var cmd = new AddExistingNetModuleToAssemblyCommand((AssemblyTreeNode)nodes[0], asm); UndoCommandManager.Instance.Add(cmd); MainWindow.Instance.JumpToReference(cmd.modNode); }
protected override void ExecuteInternal(ILSpyTreeNode[] nodes) { AddExistingNetModuleToAssemblyCommand.Execute(nodes); }
static void Execute(Lazy<IUndoCommandManager> undoCommandManager, IAppWindow appWindow, IFileTreeNodeData[] nodes) { if (!AddNetModuleToAssemblyCommand.CanExecute(nodes)) return; var dialog = new System.Windows.Forms.OpenFileDialog() { Filter = PickFilenameConstants.NetModuleFilter, RestoreDirectory = true, }; if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; if (string.IsNullOrEmpty(dialog.FileName)) return; var fm = appWindow.FileTreeView.FileManager; var file = DnSpyFile.CreateDnSpyFileFromFile(DnSpyFileInfo.CreateFile(dialog.FileName), dialog.FileName, fm.Settings.UseMemoryMappedIO, fm.Settings.LoadPDBFiles, fm.AssemblyResolver, true); if (file.ModuleDef == null || file.AssemblyDef != null || !(file is IDnSpyDotNetFile)) { Shared.App.MsgBox.Instance.Show(string.Format(dnSpy_AsmEditor_Resources.Error_NotNetModule, file.Filename), MsgBoxButton.OK); var id = file as IDisposable; if (id != null) id.Dispose(); return; } var node = (IDnSpyFileNode)nodes[0]; var newModNode = node.Context.FileTreeView.CreateModule((IDnSpyDotNetFile)file); var cmd = new AddExistingNetModuleToAssemblyCommand(undoCommandManager.Value, node, newModNode); undoCommandManager.Value.Add(cmd); appWindow.FileTabManager.FollowReference(cmd.modNode); }
static void Execute(ILSpyTreeNode[] nodes) { if (!AddNetModuleToAssemblyCommand.CanExecute(nodes)) return; var dialog = new System.Windows.Forms.OpenFileDialog() { Filter = PickFilenameConstants.NetModuleFilter, RestoreDirectory = true, }; if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; if (string.IsNullOrEmpty(dialog.FileName)) return; var asm = MainWindow.Instance.DnSpyFileList.CreateDnSpyFile(dialog.FileName); if (asm.ModuleDef == null || asm.AssemblyDef != null) { MainWindow.Instance.ShowMessageBox(string.Format("{0} is not a NetModule", asm.Filename), System.Windows.MessageBoxButton.OK); asm.Dispose(); return; } var cmd = new AddExistingNetModuleToAssemblyCommand((AssemblyTreeNode)nodes[0], asm); UndoCommandManager.Instance.Add(cmd); MainWindow.Instance.JumpToReference(cmd.modNode); }
static void Execute(Lazy<IUndoCommandService> undoCommandService, IAppService appService, DocumentTreeNodeData[] nodes) { if (!AddNetModuleToAssemblyCommand.CanExecute(nodes)) return; var dialog = new System.Windows.Forms.OpenFileDialog() { Filter = PickFilenameConstants.NetModuleFilter, RestoreDirectory = true, }; if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; if (string.IsNullOrEmpty(dialog.FileName)) return; var fm = appService.DocumentTreeView.DocumentService; var file = fm.CreateDocument(DsDocumentInfo.CreateDocument(dialog.FileName), dialog.FileName, true); if (file.ModuleDef == null || file.AssemblyDef != null || !(file is IDsDotNetDocument)) { MsgBox.Instance.Show(string.Format(dnSpy_AsmEditor_Resources.Error_NotNetModule, file.Filename), MsgBoxButton.OK); var id = file as IDisposable; if (id != null) id.Dispose(); return; } var node = (DsDocumentNode)nodes[0]; var newModNode = node.Context.DocumentTreeView.CreateModule((IDsDotNetDocument)file); var cmd = new AddExistingNetModuleToAssemblyCommand(undoCommandService.Value, node, newModNode); undoCommandService.Value.Add(cmd); appService.DocumentTabService.FollowReference(cmd.modNode); }