Exemplo n.º 1
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!AddNetModuleToAssemblyCommand.CanExecute(nodes))
            {
                return;
            }

            var asmNode = (AssemblyTreeNode)nodes[0];

            if (asmNode.Parent is AssemblyTreeNode)
            {
                asmNode = (AssemblyTreeNode)asmNode.Parent;
            }

            var win  = new NetModuleOptionsDlg();
            var data = new NetModuleOptionsVM(asmNode.LoadedAssembly.ModuleDefinition);

            win.DataContext = data;
            win.Owner       = MainWindow.Instance;
            if (win.ShowDialog() != true)
            {
                return;
            }

            UndoCommandManager.Instance.Add(new AddNewNetModuleToAssemblyCommand((AssemblyTreeNode)nodes[0], data.CreateNetModuleOptions()));
        }
Exemplo n.º 2
0
        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);
                if (asm.ModuleDefinition != null)
                {
                    asm.ModuleDefinition.Dispose();
                }
                return;
            }

            UndoCommandManager.Instance.Add(new AddExistingNetModuleToAssemblyCommand((AssemblyTreeNode)nodes[0], asm));
        }
Exemplo n.º 3
0
 protected override bool CanExecuteInternal(ILSpyTreeNode[] nodes)
 {
     return(AddNetModuleToAssemblyCommand.CanExecute(nodes));
 }