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

            var methodNode = (MethodTreeNode)nodes[0];

            var module = ILSpyTreeNode.GetModule(nodes[0]);

            Debug.Assert(module != null);
            if (module == null)
            {
                throw new InvalidOperationException();
            }

            var data = new MethodOptionsVM(new MethodDefOptions(methodNode.MethodDefinition), module, MainWindow.Instance.CurrentLanguage, methodNode.MethodDefinition.DeclaringType, methodNode.MethodDefinition);
            var win  = new MethodOptionsDlg();

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

            UndoCommandManager.Instance.Add(new MethodDefSettingsCommand(methodNode, data.CreateMethodDefOptions()));
        }
Exemplo n.º 2
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!CanExecute(nodes))
            {
                return;
            }

            var ownerNode = nodes[0];

            if (!(ownerNode is TypeTreeNode))
            {
                ownerNode = (ILSpyTreeNode)ownerNode.Parent;
            }
            var typeNode = ownerNode as TypeTreeNode;

            Debug.Assert(typeNode != null);
            if (typeNode == null)
            {
                throw new InvalidOperationException();
            }

            var module = ILSpyTreeNode.GetModule(typeNode);

            Debug.Assert(module != null);
            if (module == null)
            {
                throw new InvalidOperationException();
            }

            bool isInstance = !(typeNode.TypeDefinition.IsAbstract && typeNode.TypeDefinition.IsSealed);
            var  sig        = isInstance ? MethodSig.CreateInstance(module.CorLibTypes.Void) : MethodSig.CreateStatic(module.CorLibTypes.Void);
            var  options    = MethodDefOptions.Create("MyMethod", sig);

            if (typeNode.TypeDefinition.IsInterface)
            {
                options.Attributes |= MethodAttributes.Abstract | MethodAttributes.Virtual | MethodAttributes.NewSlot;
            }

            var data = new MethodOptionsVM(options, module, MainWindow.Instance.CurrentLanguage, typeNode.TypeDefinition, null);
            var win  = new MethodOptionsDlg();

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

            UndoCommandManager.Instance.Add(new CreateMethodDefCommand(typeNode, data.CreateMethodDefOptions()));
        }
Exemplo n.º 3
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!CanExecute(nodes))
                return;

            var methodNode = (MethodTreeNode)nodes[0];

            var module = ILSpyTreeNode.GetModule(nodes[0]);
            Debug.Assert(module != null);
            if (module == null)
                throw new InvalidOperationException();

            var data = new MethodOptionsVM(new MethodDefOptions(methodNode.MethodDefinition), module, MainWindow.Instance.CurrentLanguage, methodNode.MethodDefinition.DeclaringType, methodNode.MethodDefinition);
            var win = new MethodOptionsDlg();
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            if (win.ShowDialog() != true)
                return;

            UndoCommandManager.Instance.Add(new MethodDefSettingsCommand(methodNode, data.CreateMethodDefOptions()));
        }
Exemplo n.º 4
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!CanExecute(nodes))
                return;

            var ownerNode = nodes[0];
            if (!(ownerNode is TypeTreeNode))
                ownerNode = (ILSpyTreeNode)ownerNode.Parent;
            var typeNode = ownerNode as TypeTreeNode;
            Debug.Assert(typeNode != null);
            if (typeNode == null)
                throw new InvalidOperationException();

            var module = ILSpyTreeNode.GetModule(typeNode);
            Debug.Assert(module != null);
            if (module == null)
                throw new InvalidOperationException();

            bool isInstance = !(typeNode.TypeDefinition.IsAbstract && typeNode.TypeDefinition.IsSealed);
            var sig = isInstance ? MethodSig.CreateInstance(module.CorLibTypes.Void) : MethodSig.CreateStatic(module.CorLibTypes.Void);
            var options = MethodDefOptions.Create("MyMethod", sig);
            if (typeNode.TypeDefinition.IsInterface)
                options.Attributes |= MethodAttributes.Abstract | MethodAttributes.Virtual | MethodAttributes.NewSlot;

            var data = new MethodOptionsVM(options, module, MainWindow.Instance.CurrentLanguage, typeNode.TypeDefinition, null);
            var win = new MethodOptionsDlg();
            win.Title = "Create Method";
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            if (win.ShowDialog() != true)
                return;

            UndoCommandManager.Instance.Add(new CreateMethodDefCommand(typeNode, data.CreateMethodDefOptions()));
        }