예제 #1
0
        private void ConfirmPropertyDeclarationsToBeWrappedAndContinueWrapping(IClassDeclaration classDeclaration, IConstructEnumerable <IMemberDeclaration> propertiesForWrapping)
        {
            List <string> confirmedPropertiesNamesForWrapping = new List <string>();

            foreach (IMemberDeclaration propertyDeclaration in propertiesForWrapping)
            {
                if (classDeclaration.FileModel.UIProcess.Get <ConfirmOccurencesDialog>().Confirm(propertyDeclaration, true))
                {
                    confirmedPropertiesNamesForWrapping.Add(propertyDeclaration.Identifier.Name);
                }
            }

            if (propertiesSelectedByUser)
            {
                string            classDeclarationFullName = classDeclaration.FullName;
                IClassDeclaration viewModel = CreateViewModelWithoutUserSelectedProperties(classDeclaration);
                viewModel = RebuildSolutionModel(classDeclaration, viewModel.Identifier.Name);
                IFieldDeclaration  wrappedField            = viewModel.ContainedDeclarations.First(d => d.Is <IFieldDeclaration>()).As <IFieldDeclaration>();
                IMethodDeclaration onPropertyChangedMethod = viewModel.ContainedDeclarations.First(d => d.Is <IMethodDeclaration>()).As <IMethodDeclaration>();
                classDeclaration = viewModel.FileModel.All <IClassDeclaration>().First(c => string.Equals(c.FullName, classDeclarationFullName, System.StringComparison.Ordinal));

                List <IPropertyDeclaration> confirmedPropertiesForWrapping = GetPropertiesForWrappingByName(classDeclaration, confirmedPropertiesNamesForWrapping);

                InsertWrappedProperties(viewModel, confirmedPropertiesForWrapping, wrappedField, onPropertyChangedMethod.Identifier);
                viewModel.NavigateTo();
            }
            else
            {
                propertiesSelectedByUser = true;
            }
        }