Example #1
0
 /// <summary>
 ///     Determine if this object and the object in question are equal.
 /// </summary>
 /// <param name="obj">The object to compare this object against.</param>
 /// <returns><code>true</code> if the objects are equal, or
 ///     <code>false</code> if the two objects are not equal.</returns>
 public override bool Equals(object obj)
 {
     if (obj is FileComparator)
     {
         FileComparator that = (FileComparator)obj;
         return(this.filename == that.filename);
     }
     return(false);
 }
Example #2
0
        /// <summary>
        ///     Compare the specified file to the given.  Return
        ///         1 - if this object is greater than the given object.
        ///         0 - if this object is equal to the given object.
        ///        -1 - if this object is less than the given object.
        /// </summary>
        public int CompareTo(object obj)
        {
            if (obj is FileComparator)
            {
                FileComparator that = (FileComparator)obj;

                if (File.Exists(this.filename) && File.Exists(that.filename))
                {
                    StreamReader thisReader = new StreamReader(this.filename);
                    StreamReader thatReader = new StreamReader(that.filename);

                    String thisContents = thisReader.ReadToEnd();
                    String thatContents = thatReader.ReadToEnd();

                    return(thisContents.CompareTo(thatContents));
                }
                else
                {
                    return(0);
                }
            }
            return(-1);
        }