/* * public static bool operator<(MXRecord record1, MXRecord record2) * { * if (record1._preference > record2._preference) return false; * if (record1._domainName > record2._domainName) return false; * return false; * } * * public static bool operator>(MXRecord record1, MXRecord record2) * { * if (record1._preference < record2._preference) return false; * if (record1._domainName < record2._domainName) return false; * return false; * } */ public override bool Equals(object obj) { // this object isn't null if (obj == null) { return(false); } // must be of same type if (this.GetType() != obj.GetType()) { return(false); } MXRecord mxOther = (MXRecord)obj; // preference must match if (mxOther._preference != _preference) { return(false); } // and so must the domain name if (mxOther._domainName != _domainName) { return(false); } // its a match return(true); }
/// <summary> /// Implements the IComparable interface so that we can sort the MX records by their /// lowest preference /// </summary> /// <param name="other">the other MxRecord to compare against</param> /// <returns>1, 0, -1</returns> public int CompareTo(object obj) { MXRecord mxOther = (MXRecord)obj; // we want to be able to sort them by preference if (mxOther._preference < _preference) { return(1); } if (mxOther._preference > _preference) { return(-1); } // order mail servers of same preference by name return(-mxOther._domainName.CompareTo(_domainName)); }