public override int GetHashCode() { // http://stackoverflow.com/questions/670063/getting-hash-of-a-list-of-strings-regardless-of-order // Items are unique - probability of getting the same hashcode is lower. var playerDetailsHash = PlayersDetails.Aggregate(0, (i, details) => i ^ details.GetHashCode()); var damageDetailshash = DamagesDetails.Aggregate(0, (i, details) => i ^ details.GetHashCode()); return(unchecked (((PlayersDetails.Count() * 397) ^ playerDetailsHash) + ((DamagesDetails.Count() * 397) ^ damageDetailshash))); }
public bool Equals(BroadcastMessage other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } // http://stackoverflow.com/questions/3669970/compare-two-listt-objects-for-equality-ignoring-order // Items are unique - so lists like {x, x, y} and {x, y, y} are not checked. // So, checking item count for equality and checking all items in one list for existance in the other is enough. var playerDetailsEquality = PlayersDetails.Count() == other.PlayersDetails.Count() && PlayersDetails.All(other.PlayersDetails.Contains); var damageDetailsEquality = DamagesDetails.Count() == other.DamagesDetails.Count() && DamagesDetails.All(other.DamagesDetails.Contains); return(playerDetailsEquality && damageDetailsEquality); }