public override int GetHashCode() { var result = 17; var fields = new[] { PostalCountry, AdministrativeArea, Locality, DependentLocality, PostalCode, SortingCode, Organization, Recipient, LanguageCode }; foreach (var field in fields) { result = 31 * result + (field == null ? 0 : field.GetHashCode()); } result = 31 * result + (!AddressLines.Any() ? 0 : AddressLines.GetHashCode()); return(result); }
public override bool Equals(object obj) { if (obj == this) { return(true); } if (!(obj is AddressData addressData)) { return(false); } return((PostalCountry == null ? addressData.PostalCountry == null : PostalCountry.Equals(addressData.PostalCountry)) && (!AddressLines.Any() ? !addressData.AddressLines.Any() : AddressLines.Equals(addressData.AddressLines)) && (AdministrativeArea == null ? addressData.AdministrativeArea == null : AdministrativeArea.Equals(addressData.AdministrativeArea)) && (Locality == null ? addressData.Locality == null : Locality.Equals(addressData.Locality)) && (DependentLocality == null ? addressData.DependentLocality == null : DependentLocality.Equals(addressData.DependentLocality)) && (PostalCode == null ? addressData.PostalCode == null : PostalCode.Equals(addressData.PostalCode)) && (SortingCode == null ? addressData.SortingCode == null : SortingCode.Equals(addressData.SortingCode)) && (Organization == null ? addressData.Organization == null : Organization.Equals(addressData.Organization)) && (Recipient == null ? addressData.Recipient == null : Recipient.Equals(addressData.Recipient)) && (LanguageCode == null ? addressData.LanguageCode == null : LanguageCode.Equals(addressData.LanguageCode))); }