Example #1
0
        internal static void Execute(Lazy <IMethodAnnotations> methodAnnotations, Lazy <IUndoCommandService> undoCommandService, IAppService appService, DocumentTreeNodeData[] nodes, uint[]?offsets = null)
        {
            if (!CanExecute(nodes))
            {
                return;
            }

            var methodNode = (MethodNode)nodes[0];

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

            Debug2.Assert(!(module is null));
            if (module is null)
            {
                throw new InvalidOperationException();
            }

            var data = new MethodBodyVM(new MethodBodyOptions(methodNode.MethodDef), module, appService.DecompilerService, methodNode.MethodDef.DeclaringType, methodNode.MethodDef);
            var win  = new MethodBodyDlg();

            win.DataContext = data;
            win.Owner       = appService.MainWindow;
            win.Title       = $"{win.Title} - {methodNode.ToString()}";

            if (data.IsCilBody && !(offsets is null))
            {
                data.CilBodyVM.Select(offsets);
            }

            if (win.ShowDialog() != true)
            {
                return;
            }

            undoCommandService.Value.Add(new EditMethodBodyILCommand(methodAnnotations.Value, methodNode, data.CreateMethodBodyOptions()));
        }
Example #2
0
        internal static void Execute(ILSpyTreeNode[] nodes, uint[] offsets = null)
        {
            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 MethodBodyVM(new MethodBodyOptions(methodNode.MethodDefinition), module, MainWindow.Instance.CurrentLanguage, methodNode.MethodDefinition.DeclaringType, methodNode.MethodDefinition);
            var win  = new MethodBodyDlg();

            win.DataContext = data;
            win.Owner       = MainWindow.Instance;
            win.Title       = string.Format("{0} - {1}", win.Title, methodNode.ToString());

            if (data.IsCilBody && offsets != null)
            {
                data.CilBodyVM.Select(offsets);
            }

            if (win.ShowDialog() != true)
            {
                return;
            }

            UndoCommandManager.Instance.Add(new MethodBodySettingsCommand(methodNode, data.CreateMethodBodyOptions()));
        }
Example #3
0
        internal static void Execute(Lazy <IMethodAnnotations> methodAnnotations, Lazy <IUndoCommandManager> undoCommandManager, IAppWindow appWindow, IFileTreeNodeData[] nodes, uint[] offsets = null)
        {
            if (!CanExecute(nodes))
            {
                return;
            }

            var methodNode = (IMethodNode)nodes[0];

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

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

            var data = new MethodBodyVM(new MethodBodyOptions(methodNode.MethodDef), module, appWindow.LanguageManager, methodNode.MethodDef.DeclaringType, methodNode.MethodDef);
            var win  = new MethodBodyDlg();

            win.DataContext = data;
            win.Owner       = appWindow.MainWindow;
            win.Title       = string.Format("{0} - {1}", win.Title, methodNode.ToString());

            if (data.IsCilBody && offsets != null)
            {
                data.CilBodyVM.Select(offsets);
            }

            if (win.ShowDialog() != true)
            {
                return;
            }

            undoCommandManager.Value.Add(new EditMethodBodyILCommand(methodAnnotations.Value, methodNode, data.CreateMethodBodyOptions()));
        }
Example #4
0
		internal static void Execute(Lazy<IMethodAnnotations> methodAnnotations, Lazy<IUndoCommandService> undoCommandService, IAppService appService, DocumentTreeNodeData[] nodes, uint[] offsets = null) {
			if (!CanExecute(nodes))
				return;

			var methodNode = (MethodNode)nodes[0];

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

			var data = new MethodBodyVM(new MethodBodyOptions(methodNode.MethodDef), module, appService.DecompilerService, methodNode.MethodDef.DeclaringType, methodNode.MethodDef);
			var win = new MethodBodyDlg();
			win.DataContext = data;
			win.Owner = appService.MainWindow;
			win.Title = string.Format("{0} - {1}", win.Title, methodNode.ToString());

			if (data.IsCilBody && offsets != null)
				data.CilBodyVM.Select(offsets);

			if (win.ShowDialog() != true)
				return;

			undoCommandService.Value.Add(new EditMethodBodyILCommand(methodAnnotations.Value, methodNode, data.CreateMethodBodyOptions()));
		}
Example #5
0
        internal static void Execute(ILSpyTreeNode[] nodes, uint[] offsets = null)
        {
            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 MethodBodyVM(new MethodBodyOptions(methodNode.MethodDefinition), module, MainWindow.Instance.CurrentLanguage, methodNode.MethodDefinition.DeclaringType, methodNode.MethodDefinition);
            var win = new MethodBodyDlg();
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            win.Title = string.Format("{0} - {1}", win.Title, methodNode.ToString());

            if (data.IsCilBody && offsets != null)
                data.CilBodyVM.Select(offsets);

            if (win.ShowDialog() != true)
                return;

            UndoCommandManager.Instance.Add(new MethodBodySettingsCommand(methodNode, data.CreateMethodBodyOptions()));
        }