Example #1
0
        private string CopyTypeTree()
        {
            TreeInfo info     = (TreeInfo)DumpListView.Items[DumpListView.SelectedIndex];
            TreeDump typeTree = Dump.TypeTrees.FirstOrDefault(t => t.ClassID == info.ID);

            if (typeTree == null)
            {
                return(string.Empty);
            }

            // header
            StringBuilder sb = new StringBuilder();

            sb.Append("// classID{").Append(typeTree.ClassID).Append("}: ").Append(typeTree.ClassName);
            for (int i = 0; i < typeTree.Inheritance.Count; i++)
            {
                sb.Append(" <- ");
                sb.Append(typeTree.Inheritance[i]);
            }
            sb.AppendLine();

            // nodes
            CopyTypeTreeNode(typeTree, 0, sb);
            sb.Length -= Environment.NewLine.Length;
            return(sb.ToString());
        }
Example #2
0
        internal static TreeDump Read(DumpReader reader)
        {
            TreeDump typeTree = new TreeDump();

            typeTree.ReadTypeTree(reader);
            return(typeTree);
        }
Example #3
0
        public override TreeNodeDump Optimize()
        {
            TreeDump tree = new TreeDump();

            Optimize(tree);
            tree.ClassID     = ClassID;
            tree.ClassName   = ClassName;
            tree.Inheritance = Inheritance;
            tree.IsValid     = IsValid;
            tree.IsAbstract  = IsAbstract;
            return(tree);
        }
Example #4
0
        public TreeDiff(TreeDump tree, DiffStatus status)
        {
            if (tree == null)
            {
                throw new ArgumentNullException(nameof(tree));
            }

            ClassID       = tree.ClassID;
            LeftClassName = RightClassName = tree.ClassName ?? throw new ArgumentNullException(nameof(tree.ClassName));
            LeftBaseName  = RightBaseName = tree.Inheritance.Count == 0 ? string.Empty : tree.Inheritance[0] ?? throw new ArgumentNullException("BaseName");
            Node          = tree.IsAbstract || !tree.IsValid ? null : new TreeNodeDiff(tree, status);
            Status        = status;
        }
Example #5
0
        private void ReadInner(DumpReader reader)
        {
            Version = ReadVersion(reader);
            Type    = ReadType(reader);

            List <TreeDump> trees = new List <TreeDump>();

            while (!ReadValidation(reader, trees))
            {
                TreeDump tree = TreeDump.Read(reader);
                trees.Add(tree);
            }
            TypeTrees = trees.ToArray();
        }
Example #6
0
        public DBDump Optimize()
        {
            DBDump db = new DBDump();

            db.Version = Version;
            db.Type    = Type;
            TreeDump[] typeTrees = new TreeDump[TypeTrees.Count];
            for (int i = 0; i < TypeTrees.Count; i++)
            {
                typeTrees[i] = (TreeDump)TypeTrees[i].Optimize();
            }
            db.TypeTrees = typeTrees;
            return(db);
        }
Example #7
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);
        }
Example #8
0
        public TreeDiff(TreeDump left, TreeDump right)
        {
            if (left == null)
            {
                throw new ArgumentNullException(nameof(left));
            }
            if (right == null)
            {
                throw new ArgumentNullException(nameof(right));
            }
            if (left.ClassID != right.ClassID)
            {
                throw new ArgumentException($"Left class ID {left.ClassID} doesn't match to right {right.ClassID}");
            }

            ClassID        = left.ClassID;
            LeftClassName  = left.ClassName ?? throw new ArgumentNullException(nameof(left.ClassName));
            RightClassName = right.ClassName ?? throw new ArgumentNullException(nameof(right.ClassName));
            LeftBaseName   = left.Inheritance.Count == 0 ? string.Empty : left.Inheritance[0] ?? throw new ArgumentNullException("BaseName");
            RightBaseName  = right.Inheritance.Count == 0 ? string.Empty : right.Inheritance[0] ?? throw new ArgumentNullException("BaseName");
            if (left.IsValid && right.IsValid)
            {
                if (left.IsAbstract || right.IsAbstract)
                {
                    Status = (LeftClassName == RightClassName && LeftBaseName == RightBaseName) ? DiffStatus.Unchanged : DiffStatus.Changed;
                }
                else
                {
                    Node   = new TreeNodeDiff(left, right);
                    Status = (LeftClassName == RightClassName && LeftBaseName == RightBaseName) ? Node.DeepStatus : DiffStatus.Changed;
                }
            }
            else
            {
                Status = DiffStatus.Invalid;
            }
        }
Example #9
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();
        }
Example #10
0
 public TreeNodeDiff(TreeDump left, TreeDump right) :
     this(left, right, true)
 {
 }