src/Misc/EFTools/DesignXmlCore/Refactoring/RefactoringOperationBase.cs
/// <summary>
///     The DoOperation method begins the entire refactoring process.
///     The launch point for the refactoring operation must call this method.
///     overall flow
///     1) UI flows input into an instance of a derivation of this class ... (ctor)
///     2) The class may present its own UI (cancel)
///     3) It creates an ContributorInput object
///     4) Feeds it to the manager (or base class, depending on how you look at it)
///     5) Proposals returned
///     6) Merge proposals
///     7) Preview UI (optional)kind
///     8) Apply changes (or cancel or fail)
/// </summary>
The DoOperation method begins the entire refactoring process.
The launch point for the refactoring operation must call this method.
overall flow
1) UI flows input into an instance of a derivation of this class ... (ctor)
2) The class may present its own UI (cancel)
3) It creates an ContributorInput object
4) Feeds it to the manager (or base class, depending on how you look at it)
5) Proposals returned
6) Merge proposals
7) Preview UI (optional)kind
8) Apply changes (or cancel or fail)
The DoOperation method begins the entire refactoring process . The launch point for the refactoring operation must call this method . overall flow 1 ) UI flows input into an instance of a derivation of this class ... ( ctor ) 2 ) The class may present its own UI ( cancel ) 3 ) It creates an ContributorInput object 4 ) Feeds it to the manager ( or base class depending on how you look at it ) 5 ) Proposals returned 6 ) Merge proposals 7 ) Preview UI ( optional ) kind 8 ) Apply changes ( or cancel or fail )
public void DoOperation()
        {
            try
            {
                if (ContributorInput == null)
                {
                    ContributorInput = OnGetContributorInput();
                }
                if (ErrorOccurred || IsCancelled)
                {
                    return;
                }
                if (ContributorInput == null)
                {
                    throw new InvalidOperationException();
                }
                FileChanges = GetFileChanges();
                using (var cursor = WaitCursorHelper.NewWaitCursor())
                {
                    if (HasPreviewWindow)
                    {
                        OnBeforeShowPreviewWindow();
                        if (ErrorOccurred || IsCancelled)
                        {
                            return;
                        }
                        if (PreviewData.ChangeList == null
                            || PreviewData.ChangeList.Count == 0)
                        {
                            if (System.Windows.MessageBox.Show(
                                    Resources.RefactoringOperation_NoChangesToPreview,
                                    Resources.RefactoringOperation_NoChangesToPreviewTitle,
                                    MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                            {
                                ApplyChanges();
                            }
                        }
                        else
                        {
                            ShowPreviewWindow();
                        }
                    }
                    else
                    {
                        ApplyChanges();
                    }
                }
                if (ErrorOccurred || IsCancelled)
                {
                    return;
                }
            }
            catch (InvalidOperationException ex)
            {
                OnError(string.Format(CultureInfo.CurrentCulture, Resources.Error_FailedOperation, ex.Message));
            }
            catch (OperationCanceledException ex)
            {
                var errorMessage = ex.Message;
                if (string.IsNullOrEmpty(errorMessage))
                {
                    errorMessage = Resources.Dialog_CancelRefactoring;
                }
                CancelOperation();
                CommonVsUtilities.ShowMessageBoxEx(
                    Resources.RefactorDialog_Title, errorMessage,
                    MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Error);
            }
            finally
            {
                UnregisterEvents();
            }
        }
public void DoOperation ( ) { try { if ( ContributorInput == null ) { ContributorInput = OnGetContributorInput ( ) ; } if ( ErrorOccurred || IsCancelled ) { return ; } if ( ContributorInput == null ) { throw new InvalidOperationException ( ) ; } FileChanges = GetFileChanges ( ) ; using ( var cursor = WaitCursorHelper . NewWaitCursor ( ) ) { if ( HasPreviewWindow ) { OnBeforeShowPreviewWindow ( ) ; if ( ErrorOccurred || IsCancelled ) { return ; } if ( PreviewData . ChangeList == null || PreviewData . ChangeList . Count == 0 ) { if ( System . Windows . MessageBox . Show ( Resources . RefactoringOperation_NoChangesToPreview , Resources . RefactoringOperation_NoChangesToPreviewTitle , MessageBoxButton . OKCancel ) == MessageBoxResult . OK ) { ApplyChanges ( ) ; } } else { ShowPreviewWindow ( ) ; } } else { ApplyChanges ( ) ; } } if ( ErrorOccurred || IsCancelled ) { return ; } } catch ( InvalidOperationException ex ) { OnError ( string . Format ( CultureInfo . CurrentCulture , Resources . Error_FailedOperation , ex . Message ) ) ; } catch ( OperationCanceledException ex ) { var errorMessage = ex . Message ; if ( string . IsNullOrEmpty ( errorMessage ) ) { errorMessage = Resources . Dialog_CancelRefactoring ; } CancelOperation ( ) ; CommonVsUtilities . ShowMessageBoxEx ( Resources . RefactorDialog_Title , errorMessage , MessageBoxButtons . OK , MessageBoxDefaultButton . Button1 , MessageBoxIcon . Error ) ; } finally { UnregisterEvents ( ) ; } }
The DoOperation method begins the entire refactoring process.
The DoOperation method begins the entire refactoring process .
// If we don't have a ContributorInput yet, call OnGetContributorInput method to get ContributorInput for this operation. // If not cancelled and contributorInput is null, throw exception. // Collect the list of files to change // Log names of files with error to event log // After feed the preview window with PreviewChangesEngine, the engine will call back the ApplyChanges // method in this Operation if user clicks Apply button. // If no preview needed, apply the changes.