/// <summary> /// Override of the get hash code method. /// </summary> /// <returns></returns> public override int GetHashCode() { //Get hash code for the nullable fields. int hashLogin = Login == null ? 0 : Login.GetHashCode(); int hashPassword = Password == null ? 0 : Password.GetHashCode(); int hashDailyMeals = DailyMeals == null ? 0 : DailyMeals.Distinct().Aggregate(0, (x, y) => x.GetHashCode() ^ y.GetHashCode());; //Calculate the hash code for the GPOPolicy. return(_id.GetHashCode() ^ TimeBetweenMeals.GetHashCode() ^ Language.GetHashCode() ^ hashLogin ^ hashPassword ^ hashDailyMeals); }
/// <summary> /// Override of the equality method. /// </summary> /// <param name="o"></param> /// <returns></returns> public bool Equals(Users o) { //Check whether the compared object is null. if (ReferenceEquals(o, null)) { return(false); } //Check whether the compared object references the same data. if (ReferenceEquals(this, o)) { return(true); } //Check whether the Users' properties are equal. return(_id.Equals(o._id) && TimeBetweenMeals.Equals(o.TimeBetweenMeals) && Language.Equals(o.Language) && Login.Equals(o.Login) && Password.Equals(o.Password) && Tools.SequenceEqual(DailyMeals, o.DailyMeals)); }