예제 #1
0
        public override void Invoke()
        {
            var stickProcessor = new ControllerDomain(_codeModel.Parent.ContainingProject);

            var stincks = stickProcessor.FindStinck(new[] { _controller });
            var stinck  = stincks.FirstOrDefault();

            var form = new SelectElementsForm();

            form.SetWindowData(stinck, _actionName == null ? RefactorTarget.ServiceActions : RefactorTarget.ServiceAction, _actionName);

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                stickProcessor.FindControllerRelativeClasses(stinck.Name);
                var result = stickProcessor.GenerateRefactoringCode(form.GetData());
                stickProcessor.AddToProject(result);
            }
        }
예제 #2
0
        public void SetWindowData(ControllerStinck controller, RefactorTarget target, string targetName = null)
        {
            _stinck = controller.Clone();

            clbViewModel.Items.Clear();
            clbService.Items.Clear();

            foreach (var vmAction in controller.ViewModelMethods.Union(controller.BadPublicMethods))
            {
                var check = (target == RefactorTarget.ViewModelAction && targetName == vmAction.Name) ||
                            (target == RefactorTarget.BaseViewModel && (vmAction.Name == "Get" || vmAction.Name == "List")) ||
                            (target == RefactorTarget.ViewModelActions || target == RefactorTarget.Controller);

                clbViewModel.Items.Add(vmAction.Name, check);
            }

            foreach (var svcAction in controller.ServiceMethods)
            {
                var check = (target == RefactorTarget.ServiceAction && targetName == svcAction.Name) ||
                            (target == RefactorTarget.ServiceActions || target == RefactorTarget.Controller);

                clbService.Items.Add(svcAction.Name, check);
            }

            _funcs = _stinck.ViewModelMethods.Union(_stinck.BadPublicMethods).Union(_stinck.ServiceMethods);

            var stickProcessor = new ControllerDomain(controller.ProjectItem.ContainingProject);

            stickProcessor.FindControllerRelativeClasses(controller.Name);
            var result = stickProcessor.GenerateRefactoringCode(_stinck);

            try
            {
                _convertedCode = result.Modification.ConvertedMethods;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + "     " + e.StackTrace);
            }
        }