Exemplo n.º 1
0
        public void ShowTypeTreeView(int classID)
        {
            TreeDump            treeDump = Dump.TypeTrees.FirstOrDefault(t => t.ClassID == classID);
            TreeDiff            treeDiff = Diff.TreeDiffs.First(t => t.ClassID == classID);
            List <TreeNodeInfo> items    = new List <TreeNodeInfo>();

            if (treeDump == null)
            {
                items.Add(TreeNodeInfo.Empty);
            }
            else
            {
                string baseHierarchy = string.Join(" <= ", treeDump.Inheritance);
                string hierarchy     = baseHierarchy == string.Empty ? treeDump.ClassName : treeDump.ClassName + " <= " + baseHierarchy;

                DiffStatus headerStatus = DiffStatus.Changed;
                if (treeDiff.Status == DiffStatus.Added || treeDiff.Status == DiffStatus.Deleted || treeDiff.Status == DiffStatus.Invalid)
                {
                    headerStatus = treeDiff.Status;
                }
                else
                {
                    if (treeDiff.LeftClassName == treeDiff.RightClassName)
                    {
                        if (treeDiff.LeftBaseName == treeDiff.RightBaseName)
                        {
                            headerStatus = DiffStatus.Unchanged;
                        }
                    }
                }
                TreeNodeInfo info = new TreeNodeInfo()
                {
                    Type = hierarchy, Status = headerStatus
                };
                items.Add(info);
            }

            if (treeDiff.Node != null)
            {
                items.Add(TreeNodeInfo.Empty);

                FillTypeTreeItems(items, treeDiff.Node, 0);
            }

            TypeTreeListBox.ItemsSource = items;
            DumpListView.Visibility     = Visibility.Hidden;
            TypeTreeArea.Visibility     = Visibility.Visible;
            CopyContentButton.Content   = "Copy struct";
            SetTypeTreeScrollPosition(0.0);
        }
Exemplo n.º 2
0
        public DBDiff(DBDump left, DBDump right)
        {
            if (left == null)
            {
                throw new ArgumentNullException(nameof(left));
            }
            if (right == null)
            {
                throw new ArgumentNullException(nameof(right));
            }

            LeftVersion  = left.Version;
            RightVersion = right.Version;

            Dictionary <int, TreeDump> leftTrees = new Dictionary <int, TreeDump>(left.TypeTrees.Count);

            foreach (TreeDump leftTree in left.TypeTrees)
            {
                leftTrees.Add(leftTree.ClassID, leftTree);
            }
            Dictionary <int, TreeDump> rightTrees = new Dictionary <int, TreeDump>(right.TypeTrees.Count);

            foreach (TreeDump rightTree in right.TypeTrees)
            {
                rightTrees.Add(rightTree.ClassID, rightTree);
            }

            List <TreeDiff> treeDiffs = new List <TreeDiff>();

            for (int li = 0, ri = 0; li < left.TypeTrees.Count; li++)
            {
                TreeDump leftTree = left.TypeTrees[li];
                if (rightTrees.TryGetValue(leftTree.ClassID, out TreeDump rightTree))
                {
                    TreeDiff treeDiff = new TreeDiff(leftTree, rightTree);
                    treeDiffs.Add(treeDiff);
                    rightTrees.Remove(leftTree.ClassID);
                }
                else
                {
                    TreeDiff treeDiff = new TreeDiff(leftTree, DiffStatus.Deleted);
                    treeDiffs.Add(treeDiff);
                }

                while (ri < right.TypeTrees.Count)
                {
                    TreeDump tree = right.TypeTrees[ri++];
                    if (leftTrees.ContainsKey(tree.ClassID))
                    {
                        break;
                    }
                    else
                    {
                        TreeDiff treeDiff = new TreeDiff(tree, DiffStatus.Added);
                        treeDiffs.Add(treeDiff);
                        rightTrees.Remove(tree.ClassID);
                    }
                }
            }
            foreach (TreeDump rightTree in rightTrees.Values)
            {
                TreeDiff tree = new TreeDiff(rightTree, DiffStatus.Added);
                treeDiffs.Add(tree);
            }
            TreeDiffs = treeDiffs.ToArray();
        }