コード例 #1
0
        private static List <IDifference> MatchEntriesAndCompare(ArchivePair pair)
        {
            var differences    = new List <IDifference>();
            var matchedEntries = new HashSet <string>();

            foreach (var entry1 in pair.Archive1.Entries)
            {
                var match = pair.Archive2.Entries.FirstOrDefault(e => e.Name == entry1.Name);

                if (match == null)
                {
                    //entry1 does not exist in archive2, add it to differences
                    differences.Add(new EntryDifference(entry1.Name, EntryDifference.Type.MissingEntry2));
                }
                else
                {
                    //Compare the two entries
                    GoCompare(entry1, match);
                    //Note the matching so archive2 can be processed quicker
                    matchedEntries.Add(entry1.Name);
                }
            }
            foreach (var entry2 in pair.Archive2.Entries)
            {
                if (!matchedEntries.Contains(entry2.Name))
                {
                    //entry2 does not exist in archive1 and must therefore be a difference
                    differences.Add(new EntryDifference(entry2.Name, EntryDifference.Type.MissingEntry1));
                }
            }

            return(differences);
        }
コード例 #2
0
        private static bool SnapshotFilesAreSuitable(ArchivePair pair)
        {
            try
            {
                return(ZipArchiveHasEntries(pair.Archive1) && ZipArchiveHasEntries(pair.Archive2));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(false);
        }