Пример #1
0
        private void FindDifferencesInNonquestionBlocks()
        {
            var originalBlocks = OriginalSlide.Blocks.NotOfType <SlideBlock, AbstractQuestionBlock>().ToList();
            var changedBlocks  = ChangedSlide.Blocks.NotOfType <SlideBlock, AbstractQuestionBlock>().ToList();

            foreach (var pair in originalBlocks.Zip(changedBlocks, Tuple.Create))
            {
                var isBlocksEqual = pair.Item1.XmlSerialize(true) == pair.Item2.XmlSerialize(true);
                if (!isBlocksEqual)
                {
                    var slideBlockDiff = new SlideBlockDiff(pair.Item1, pair.Item2);
                    SlideBlockDiffs.Add(slideBlockDiff);
                }
            }
        }
Пример #2
0
        private void FindDifferencesInQuestionBlocks()
        {
            var originalBlocks = OriginalSlide.Blocks.OfType <AbstractQuestionBlock>().ToList();
            var changedBlocks  = ChangedSlide.Blocks.OfType <AbstractQuestionBlock>().ToList();

            var originalBlocksIds = originalBlocks.Select(b => b.Id).ToImmutableHashSet();

            foreach (var block in originalBlocks)
            {
                var otherBlock = changedBlocks.FirstOrDefault(b => b.Id == block.Id);
                if (otherBlock == null)
                {
                    RemovedBlocks.Add(block);
                }
                else if (block.XmlSerialize(true) != otherBlock.XmlSerialize(true))
                {
                    var slideBlockDiff = new SlideBlockDiff(block, otherBlock);
                    SlideBlockDiffs.Add(slideBlockDiff);
                }
            }

            InsertedBlocks.AddRange(changedBlocks.Where(b => !originalBlocksIds.Contains(b.Id)));
        }