/// <summary> /// Override of the get hash code method. /// </summary> /// <returns></returns> public override int GetHashCode() { //Get hash code for the nullable fields. int hashLastCooked = LastCooked.HasValue ? 0 : LastCooked.GetHashCode(); int hashName = Name == null ? 0 : Name.GetHashCode(); int hashBestSeasons = BestSeasons == null ? 0 : BestSeasons.Distinct().Aggregate(0, (x, y) => x.GetHashCode() ^ y.GetHashCode());; int hashIngredients = Ingredients == null || Ingredients.Count == 0 ? 0 : Ingredients.Distinct().Aggregate(0, (x, y) => x.GetHashCode() ^ y.GetHashCode());; //Calculate the hash code for the GPOPolicy. return(_id.GetHashCode() ^ TimesCooked.GetHashCode() ^ Type.GetHashCode() ^ UserId.GetHashCode() ^ hashLastCooked ^ hashName ^ hashBestSeasons ^ hashIngredients); }
/// <summary> /// Override of the equality method. /// </summary> /// <param name="o"></param> /// <returns></returns> public bool Equals(Recipes 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 Recipes' properties are equal. return(_id.Equals(o._id) && TimesCooked.Equals(o.TimesCooked) && Type.Equals(o.Type) && UserId.Equals(o.UserId) && LastCooked.Equals(o.LastCooked) && Name.Equals(o.Name) && Tools.SequenceEqual(BestSeasons, o.BestSeasons) && Tools.SequenceEqual(Ingredients, o.Ingredients)); }