Ejemplo n.º 1
0
        public override void Execute(SolutionModel solutionModel, SelectionContext context)
        {
            FileModel fileModel;
            CodeSpan  selection;

            if (!solutionModel.IsEditorSelection(context, out fileModel, out selection))
            {
                return;
            }

            propertiesSelectedByUser = false;

            IIdentifier       identifier       = fileModel.InnerMost <IIdentifier>(selection);
            IClassDeclaration classDeclaration = identifier.ParentConstruct.As <IClassDeclaration>();

            if (classDeclaration.ExistsTextuallyInFile && classDeclaration.IsInUserCode() && !classDeclaration.IsPrivate())
            {
                IConstructEnumerable <IMemberDeclaration> propertiesForWrapping = GetPropertiesForWrapping(classDeclaration);
                if (!propertiesForWrapping.Any())
                {
                    CreateViewModelWithoutUserSelectedProperties(classDeclaration).NavigateTo();
                }
                else
                {
                    ConfirmOccurencesDialog confirmOccurencesDialog = fileModel.UIProcess.Get <ConfirmOccurencesDialog>();
                    confirmOccurencesDialog.ShowIfOccurencesToConfirmIn("Select properties for wrapping", "Select which properties to be wrapped",
                                                                        () => ConfirmPropertyDeclarationsToBeWrappedAndContinueWrapping(classDeclaration, propertiesForWrapping));
                }
            }
        }
Ejemplo n.º 2
0
        public override bool CanExecute(SolutionModel solutionModel, SelectionContext context)
        {
            FileModel fileModel;
            CodeSpan  selection;

            if (!solutionModel.IsEditorSelection(context, out fileModel, out selection))
            {
                return(false);
            }

            IIdentifier       identifier       = fileModel.InnerMost <IIdentifier>(selection);
            IClassDeclaration classDeclaration = identifier.ParentConstruct.As <IClassDeclaration>();

            return(classDeclaration.ExistsTextuallyInFile && classDeclaration.IsInUserCode() && !classDeclaration.IsPrivate());
        }