Ejemplo n.º 1
0
        private void lvStinck_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvStinck.SelectedItems.Count == 0)
            {
                return;
            }

            ControllerStinck stinck = (ControllerStinck)lvStinck.SelectedItems[0].Tag;

            lbDSVM.Items.Clear();
            lbDSVM.Items.AddRange(stinck.BadPublicMethods.Select(x => x.Name).ToArray());

            lbNested.Items.Clear();
            lbNested.Items.AddRange(stinck.NestedClasses.Select(x => x.Name).ToArray());

            lbVmOther.Items.Clear();
            lbVmOther.Items.AddRange(stinck.ViewModelMethods.Select(x => x.Name).ToArray());

            lbSvcOther.Items.Clear();
            lbSvcOther.Items.AddRange(stinck.ServiceMethods.Select(x => x.Name).ToArray());

            lbPrivate.Items.Clear();
            lbPrivate.Items.AddRange(stinck.NonPublicMethods.Select(x => x.Name).ToArray());

            lbProperties.Items.Clear();
            lbProperties.Items.AddRange(stinck.NonServiceProps.Select(x => x.Name).ToArray());

            var editor = _codeEditors["Controller"];

            editor.Text = string.Join(Environment.NewLine, ProjectItemHelper.GetFileLines(stinck.ProjectItem));
            tabCode.SelectTab("tabController");
        }
Ejemplo n.º 2
0
        private void btnCreateViewModel_Click(object sender, EventArgs e)
        {
            if (lvStinck.SelectedItems.Count == 0)
            {
                return;
            }

            _lastResult = null;
            ControllerStinck stinck = (ControllerStinck)lvStinck.SelectedItems[0].Tag;

            try
            {
                //foreach (CodeImport import in stinck.ProjectItem.FileCodeModel.CodeElements.OfType<CodeImport>())
                //{
                //    Debug.WriteLine(import.Name + "     " + import.Namespace + "        - ");
                //}

                //foreach (CodeNamespace ns in stinck.ProjectItem.FileCodeModel.CodeElements.OfType<CodeNamespace>())
                //{
                //    foreach (CodeImport import in ns.Members.OfType<CodeImport>())
                //        Debug.WriteLine("ns:  " + import.Name + "     " + import.Namespace + "        - ");
                //}
                //return;
                var result = _controllerDomain.GenerateRefactoringCode(stinck);

                foreach (var editor in _codeEditors.Values)
                {
                    editor.Tag = result.KnownTypes;
                }
                _codeEditors["ViewModelClass"].Text     = result.ViewModelClass;
                _codeEditors["ViewModelInterface"].Text = result.ViewModelInterface;
                _codeEditors["ServiceClass"].Text       = result.ServiceClass;
                _codeEditors["ServiceInterface"].Text   = result.ServiceInterface;
                //_codeEditors["DomainService"].Text = result.DomainServiceClass;
                _codeEditors["Controller"].Text = result.Controller;

                tabCode.SelectTab("tabController");
                _lastResult = result;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 3
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);
            }
        }