public int GetHashCode(BlockListDetail obj) { unchecked { return(((obj.Source != null ? obj.Source.GetHashCode() : 0) * 397) ^ (obj.Flags != null ? obj.Flags.GetHashCode() : 0)); } }
public void AddBlockListDetail(DateTime date, string source, List <Flag> flags) { BlockListDetail newBlocklistDetail = new BlockListDetail(date, source, flags); var lastMatchingBlockListDetail = this._ipAddressDateRangeDetails.BlockListDetails.LastOrDefault(x => x.Source == source); if (this._blocklistDetailsComparer.Equals(lastMatchingBlockListDetail, newBlocklistDetail)) { // ReSharper disable once PossibleNullReferenceException lastMatchingBlockListDetail.EndDate = newBlocklistDetail.EndDate; } else { this._ipAddressDateRangeDetails.BlockListDetails.Add(newBlocklistDetail); } }
public bool Equals(BlockListDetail x, BlockListDetail y) { if (ReferenceEquals(x, y)) { return(true); } if (ReferenceEquals(x, null)) { return(false); } if (ReferenceEquals(y, null)) { return(false); } if (x.GetType() != y.GetType()) { return(false); } return(string.Equals(x.Source, y.Source) && x.Flags.Count == y.Flags.Count && x.Flags.Select(flag => flag.Name).All(y.Flags.Select(flag => flag.Name).Contains)); }