Exemple #1
0
        public TreeNode(TreeNode parent, string leftPath, string rightPath, string label, FileDifference difference)
        {
            this.Parent    = parent;
            this.LeftPath  = leftPath;
            this.RightPath = rightPath;
            this.Label     = label;

            this.FileDifference = difference;
        }
Exemple #2
0
 static Brush GetBrush(FileDifference difference)
 {
     return(difference.HasFlag(FileDifference.DifferentExcludingWhiteSpace)
            ? Brushes.Red
            : (difference.HasFlag(FileDifference.DifferentInWhiteSpaceOnly)
               ? Brushes.Blue
               : (difference.HasFlag(FileDifference.LeftOnly) || difference.HasFlag(FileDifference.RightOnly)
                 ? Brushes.Green
                 : Brushes.Black)));
 }
Exemple #3
0
        private void UpdateVisibilities(ItemCollection items, FileDifference filterMask)
        {
            foreach (var i in items)
            {
                var item = i as TreeViewItem;
                if (item != null)
                {
                    var node = item.Tag as TreeNode;

                    node?.SetVisibility(item, filterMask);
                    this.UpdateVisibilities(item.Items, filterMask);
                }
            }
        }
Exemple #4
0
        internal void AddToTree(string leftPath, string rightPath, string label,
                                FileDifference differences, bool splitlabel)
        {
            var labelElements = splitlabel ? label.Split(Path.DirectorySeparatorChar) : new string[] { label };

            this.FileDifference = differences;

            var parent = this;

            for (int i = 0; (i < labelElements.Length); ++i)
            {
                string element = labelElements[i];

                if (!string.IsNullOrEmpty(element))
                {
                    if (parent.Children == null)
                    {
                        parent.Children = new List <TreeNode>();
                    }

                    var child = parent.Children.FirstOrDefault(n => StringComparer.OrdinalIgnoreCase.Equals(n.Label, element));
                    if (child == null)
                    {
                        child = (i < labelElements.Length - 1)
                                ? new TreeNode(parent, null, null, element, FileDifference.None)
                                : new TreeNode(parent, leftPath, rightPath, element, FileDifference.None);

                        parent.Children.Add(child);
                    }

                    parent = child;
                }
            }

            do
            {
                var newDifferences = differences | parent.FileDifference;
                if (parent.FileDifference == newDifferences)
                {
                    break;
                }

                parent.FileDifference = newDifferences;
                parent = parent.Parent;
            }while (parent != null);
        }
Exemple #5
0
        internal void AddToTreeView(ItemCollection items, FileDifference filterMask)
        {
            while ((this.Children != null) && (this.Children.Count == 1))
            {
                var child = this.Children[0];
                if ((child.LeftPath != null) || (child.RightPath != null) || (child.Children == null))
                {
                    break;
                }

                this.Children.RemoveAt(0);
                this.Children.AddRange(child.Children);
                foreach (var c in child.Children)
                {
                    c.Parent = this;
                }

                this.Label = this.Label + "/" + child.Label;
            }

            var tvi = new TreeViewItem();

            tvi.Tag = this;


            var box = new TextBox();

            box.Text       = this.Label;
            box.Foreground = GetBrush(this.FileDifference);

            tvi.Header = box;

            tvi.IsExpanded = true;

            SetVisibility(tvi, filterMask);

            if (this.Children != null)
            {
                foreach (var c in this.Children)
                {
                    c.AddToTreeView(tvi.Items, filterMask);
                }
            }

            items.Add(tvi);
        }
Exemple #6
0
 internal void SetVisibility(TreeViewItem item, FileDifference filterMask)
 {
     item.Visibility = ((this.FileDifference & filterMask) == FileDifference.None)
                       ? Visibility.Collapsed : Visibility.Visible;
 }
 public FileDifferenceComparer(FileDifference baselineComparisonDifferences, FileDifference checkComparisonDifferences)
 {
     BaselineComparisonDifferences = baselineComparisonDifferences;
     CheckComparisonDifferences    = checkComparisonDifferences;
 }
Exemple #8
0
        public void PartialDifferenceMialignmentTest()
        {
            string baselineDifference = @"
              {
                ""File"": ""Test_C\\Mvc_2.0_Ind_Uld_LS\\Properties\\launchSettings.json"",
                ""Differences"": [
                  {
                    ""BaselineStartPosition"": 165,
                    ""BaselineData"": ""31"",
                    ""SecondaryStartPosition"": 165,
                    ""SecondaryData"": ""64"",
                    ""LocationLeeway"": 2,
                    ""ClassificationString"": ""Integer""
                  },
                  {
                    ""BaselineStartPosition"": 691,
                    ""BaselineData"": ""30"",
                    ""SecondaryStartPosition"": 691,
                    ""SecondaryData"": ""63"",
                    ""LocationLeeway"": 2,
                    ""ClassificationString"": ""Integer""
                  }
                ]
              }
        ";

            string comparisonDifference = @"
            {
              ""File"": ""Test_C\\Mvc_2.0_Ind_Uld_LS\\Properties\\launchSettings.json"",
              ""Differences"": [
                {
                  ""BaselineStartPosition"": 162,
                  ""BaselineData"": ""56131"",
                  ""SecondaryStartPosition"": 162,
                  ""SecondaryData"": ""22963"",
                  ""LocationLeeway"": 2,
                  ""ClassificationString"": ""Integer""
                },
                {
                  ""BaselineStartPosition"": 192,
                  ""BaselineData"": ""84"",
                  ""SecondaryStartPosition"": 192,
                  ""SecondaryData"": ""33"",
                  ""LocationLeeway"": 2,
                  ""ClassificationString"": ""Integer""
                },
                {
                  ""BaselineStartPosition"": 355,
                  ""BaselineData"": ""84"",
                  ""SecondaryStartPosition"": 355,
                  ""SecondaryData"": ""33"",
                  ""LocationLeeway"": 2,
                  ""ClassificationString"": ""Integer""
                },
                {
                  ""BaselineStartPosition"": 688,
                  ""BaselineData"": ""56130"",
                  ""SecondaryStartPosition"": 688,
                  ""SecondaryData"": ""22962"",
                  ""LocationLeeway"": 2,
                  ""ClassificationString"": ""Integer""
                }
              ]
            }
        ";

            JObject baselineJObject   = JObject.Parse(baselineDifference);
            JObject comparisonJObject = JObject.Parse(comparisonDifference);

            FileDifference baselineDiff   = FileDifference.FromJObject(baselineJObject);
            FileDifference comparisonDiff = FileDifference.FromJObject(comparisonJObject);

            FileDifferenceComparer   comparer         = new FileDifferenceComparer(baselineDiff, comparisonDiff);
            FileComparisonDifference comparisonResult = comparer.Compare();

            Assert.False(comparisonResult.HasDifferenceResolutionError);
        }