Пример #1
0
        public void ShowDifferences(ShowDiffArgs e)
        {
            DirectoryDiff diff = new DirectoryDiff(
                Options.ShowOnlyInA,
                Options.ShowOnlyInB,
                Options.ShowDifferent,
                Options.ShowSame,
                Options.Recursive,
                Options.IgnoreDirectoryComparison,
                Options.FileFilter);

            DirectoryDiffResults results = diff.Execute(e.A, e.B);

            this.DiffCtrl.SetData(results);

            this.Text = string.Format("{0} : {1}", results.DirectoryA.Name, results.DirectoryB.Name);

            this.Show();

            this.lastDiffArgs = e;
        }
Пример #2
0
        private void CompareFilesCommand_Executed(string leftDir,
                                                  string rightDir,
                                                  DiffDirFileMode dirFileMode)
        {
            if (_cancelTokenSource.IsCancellationRequested == true)
            {
                return;
            }

            DirDiffArgs args = _Args;

            _Args.CompareDirFileMode = dirFileMode;

            // Construct deffault options if there are no others
            if (_Args == null)
            {
                args = new DirDiffArgs(leftDir, rightDir);
            }
            else
            {
                _Args.LeftDir  = leftDir;
                _Args.RightDir = rightDir;
            }

            var diff = new DirectoryDiff(args);

            try
            {
                _DiffProgress.ResetProgressValues(_cancelTokenSource.Token);

                Task.Factory.StartNew <IDiffProgress>(
                    (p) => diff.Execute(args.LeftDir, args.RightDir, _DiffProgress, _DataSource)
                    , TaskCreationOptions.LongRunning, _cancelTokenSource.Token)
                .ContinueWith((r) =>
                {
                    bool onError       = false;
                    bool taskCancelled = false;

                    if (_cancelTokenSource != null)
                    {
                        // Re-create cancellation token if this task was cancelled
                        // to support cancelable tasks in the future
                        if (_cancelTokenSource.IsCancellationRequested)
                        {
                            taskCancelled = true;
                            _cancelTokenSource.Dispose();
                            _cancelTokenSource = new CancellationTokenSource();
                        }
                    }

                    if (taskCancelled == false)
                    {
                        if (r.Result == null)
                        {
                            onError = true;
                        }
                        else
                        {
                            if (r.Result.ResultData == null)
                            {
                                onError = true;
                            }
                        }
                    }

                    if (onError == false && taskCancelled == false)
                    {
                        var diffResults = r.Result.ResultData as IDirectoryDiffRoot;
                        _DirDiffDoc.ShowDifferences(args, diffResults);
                    }
                    else
                    {
                        // Display Error
                    }
                });
            }
            catch
            {
                // Handle task based error and display error
            }
        }