Example #1
0
        internal bool ApplyChanges()
        {
            var args = new ApplyChangesEventArgs(FileChanges);

            try
            {
                OnPreApplyChanges(args);
                if (ErrorOccurred || IsCancelled)
                {
                    return(false);
                }

                // Apply changes
                OnApplyChanges();
                if (ErrorOccurred || IsCancelled)
                {
                    return(false);
                }

                OnPostApplyChanges(args);
                if (ErrorOccurred || IsCancelled)
                {
                    // If any error occurred during PostApplyChanges operation
                    // from different contributors, we do not need to roll back any changes.
                    return(false);
                }
            }
            catch (Exception ex)
            {
                OnError(string.Format(CultureInfo.CurrentCulture, Resources.Error_FailedOperation, ex.Message));
            }

            return(true);
        }
Example #2
0
        /// <summary>
        ///     This method allows derived RefactorOperations to perform actions post applying changes.
        /// </summary>
        /// <param name="changes"></param>
        /// <returns></returns>
        protected virtual void OnPostApplyChanges(ApplyChangesEventArgs changes)
        {
            var cache = AppliedChanges;

            if (cache != null)
            {
                cache(this, changes);
                if (changes.Cancel)
                {
                    CancelOperation();
                }
            }
        }