Exemplo n.º 1
0
 /// <summary> Initializes comparison from any two archives. </summary>
 /// <param name="left">Left archive.</param>
 /// <param name="right">Right archive.</param>
 /// <returns>true if comparison of any two archives by this trait can be performed; false otherwise.</returns>
 protected override bool InitFromArchives(Archive left, Archive right)
 {
     LeftType = left.Type;
     RightType = right.Type;
     return true;
 }
Exemplo n.º 2
0
 /// <summary> Initializes comparison from any two archives. </summary>
 /// <param name="left">Left archive.</param>
 /// <param name="right">Right archive.</param>
 /// <returns>true if comparison of any two archives by this trait can be performed; false otherwise.</returns>
 protected virtual bool InitFromArchives(Archive left, Archive right)
 {
     return false;
 }
Exemplo n.º 3
0
        /// <summary> Finds property differences between archives. </summary>
        /// <param name="left">'Left' archive.</param>
        /// <param name="right">'Right' archive.</param>
        /// <returns>Found property differences.</returns>
        public static IEnumerable<ArchiveTraitDifference> PropertiesDiff(Archive left, Archive right)
        {
            Contract.Requires(left != null);
            Contract.Requires(right != null);

            return Comparisons
                .Select(cmpType => (ArchiveTraitDifference)Activator.CreateInstance(cmpType, left, right))
                .Where(cmp => cmp != null && cmp.ComparisonExists && cmp.DifferenceExists);
        }
Exemplo n.º 4
0
        /// <summary> Finds entry differences between archives. </summary>
        /// <param name="left">'Left' archive.</param>
        /// <param name="right">'Right' archive.</param>
        /// <returns> Found entry differences. </returns>
        public static IEnumerable<EntryVersionsComparison> EntriesDiff(Archive left, Archive right)
        {
            Contract.Requires(left != null);
            Contract.Requires(right != null);

            var actualLeft = (left is SingleArchive) ? (SingleArchive)left : ((SplitArchive)left).Nested;
            var actualRight = (right is SingleArchive) ? (SingleArchive)right : ((SplitArchive)right).Nested;
            var leftEntries = actualLeft.FlattenedContents().ToList();
            var rightEntries = new HashSet<Entry>(actualRight.FlattenedContents());

            for (int i = leftEntries.Count - 1; i >= 0; i--) {
                var leftEntry = leftEntries[i];
                leftEntries.RemoveAt(i);
                var correspondingRight = rightEntries.FirstOrDefault(f => f.IsHomonymousPath(leftEntry));
                if (correspondingRight != null) {
                    rightEntries.Remove(correspondingRight);
                }

                var cmp = new EntryVersionsComparison(leftEntry, correspondingRight);
                if (cmp.State != EntryModificationState.Same) {
                    yield return cmp;
                }
            }

            foreach (var rightEntry in rightEntries) {
                yield return new EntryVersionsComparison(null, rightEntry);
            }
        }
 /// <summary> Initializes comparison from any two archives. </summary>
 /// <param name="left">Left archive.</param>
 /// <param name="right">Right archive.</param>
 /// <returns>true if comparison of any two archives by this trait can be performed; false otherwise.</returns>
 protected override bool InitFromArchives(Archive left, Archive right)
 {
     LeftPhysicalSize = left.PhysicalSize;
     RightPhysicalSize = right.PhysicalSize;
     return true;
 }
Exemplo n.º 6
0
 /// <summary> Initializes comparison from any two archives. </summary>
 /// <param name="left">Left archive.</param>
 /// <param name="right">Right archive.</param>
 /// <returns>true if comparison of any two archives by this trait can be performed; false otherwise.</returns>
 protected override bool InitFromArchives(Archive left, Archive right)
 {
     LeftFileName = left.Name;
     RightFileName = right.Name;
     return true;
 }
 /// <summary> Initializes comparison from any two archives. </summary>
 /// <param name="left">Left archive.</param>
 /// <param name="right">Right archive.</param>
 /// <returns>true if comparison of any two archives by this trait can be performed; false otherwise.</returns>
 protected override bool InitFromArchives(Archive left, Archive right)
 {
     LeftLastModified = left.LastModified;
     RightLastModified = right.LastModified;
     return true;
 }