/// <summary> /// Determines whether the specified <see cref="System.Object">Object</see> is equal /// to the current <see cref="System.Object">Object</see>. /// </summary> /// <param name="obj">The <see cref="System.Object">Object</see> to compare with the /// current <see cref="System.Object">Object</see>.</param> /// <returns><see langword="true"/> if the specified <see cref="System.Object">Object</see> /// is equal to the current <see cref="System.Object">Object</see>; otherwise, /// <see langword="false"/>.</returns> public override bool Equals(object obj) { if (obj == null) { return(false); } FindsByMobileAttribute other = obj as FindsByMobileAttribute; if (other == null) { return(false); } if (other.Priority != this.Priority) { return(false); } return(other.By.Equals(this.By)); }
/// <summary> /// Compares the current instance with another object of the same type and returns an /// integer that indicates whether the current instance precedes, follows, or occurs /// in the same position in the sort order as the other object. /// </summary> /// <param name="obj">An object to compare with this instance.</param> /// <returns>A value that indicates the relative order of the objects being compared. The return value has these meanings: /// <list type="table"> /// <listheader>Value</listheader><listheader>Meaning</listheader> /// <item><description>Less than zero</description><description>This instance precedes <paramref name="obj"/> in the sort order.</description></item> /// <item><description>Zero</description><description>This instance occurs in the same position in the sort order as <paramref name="obj"/>.</description></item> /// <item><description>Greater than zero</description><description>This instance follows <paramref name="obj"/> in the sort order. </description></item> /// </list> /// </returns> public int CompareTo(object obj) { if (obj == null) { throw new ArgumentNullException("obj", "Object to compare cannot be null"); } FindsByMobileAttribute other = obj as FindsByMobileAttribute; if (other == null) { throw new ArgumentException("Object to compare must be a FindsByAttribute", "obj"); } if (this.Priority != other.Priority) { return(this.Priority - other.Priority); } return(0); }