// ----------------------------------------------------------------------- // // Copyright (c) James South. // Dual licensed under the MIT or GPL Version 2 licenses. // // ----------------------------------------------------------------------- namespace ImageProcessor.Web.Helpers { #region Using using System; using System.Collections.Generic; #endregion /// /// Encapsulates methods to support the comparison of objects for equality. /// public class FileCompareLastwritetime : IEqualityComparer { /// /// Converts the value of the current object to its equivalent /// nearest minute representation. /// /// An instance of . /// /// A value of the current object to its equivalent /// nearest minute representation. /// public static DateTime ToMinute(DateTime value) { return new DateTime(value.Year, value.Month, value.Day, value.Hour, value.Minute, 0, value.Kind).ToUniversalTime(); } /// /// Determines whether the specified instances of object are equal. /// /// /// The first object to compare. /// /// /// The second object to compare. /// /// true if the specified objects are equal; otherwise, false. public bool Equals(System.IO.FileInfo f1, System.IO.FileInfo f2) { return ToMinute(f1.LastWriteTimeUtc) == ToMinute(f2.LastWriteTimeUtc); } /// /// Returns a hash code for the specified . /// /// The FileInfo to return the hashcode for. /// A hash code for the specified . public int GetHashCode(System.IO.FileInfo fi) { return ToMinute(fi.LastWriteTimeUtc).GetHashCode(); } } }