Example #1
0
        public static void FindMovedBlocks(Result.Block block)
        {
            foreach (Result.Block addedBlock in block.Children.Where(x => x.EntryType == EntryType.Added))
            {
                string nodeIdentity = addedBlock.Right.Identity.ToString();

                Block origin = block
                               .Children
                               .Where(x => x.EntryType == EntryType.Removed && x.Left.Identity.ToString() == nodeIdentity)
                               .FirstOrDefault();

                if (origin == null)
                {
                    continue;
                }

                // This Block has been moved!
                addedBlock.Left      = origin.Left;
                addedBlock.EntryType = EntryType.Moved;
                addedBlock.Children  = CreateResultNodeTree(addedBlock.Left.Children, addedBlock.Right.Children);

                MarkAsMoved(origin);
            }

            foreach (Block child in block.Children)
            {
                FindMovedBlocks(child);
            }
        }
Example #2
0
        public static void MarkAsMoved(Result.Block block)
        {
            block.EntryType = EntryType.MovedOrigin;

            foreach (Block child in block.Children)
            {
                MarkAsMoved(child);
            }
        }
Example #3
0
        public static Result.Block Run(INode left, INode right)
        {
            // First we do a simple diff based on the children of each node
            Result.Block result = new Result.Block
            {
                Children = CreateResultNodeTree(left.Children, right.Children),
            };

            FindMovedBlocks(result);

            result.Render();

            return(result);
        }