예제 #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is Address other &&
                   ((AddressLine1 == null && other.AddressLine1 == null) || (AddressLine1?.Equals(other.AddressLine1) == true)) &&
                   ((AddressLine2 == null && other.AddressLine2 == null) || (AddressLine2?.Equals(other.AddressLine2) == true)) &&
                   ((AddressLine3 == null && other.AddressLine3 == null) || (AddressLine3?.Equals(other.AddressLine3) == true)) &&
                   ((Locality == null && other.Locality == null) || (Locality?.Equals(other.Locality) == true)) &&
                   ((Sublocality == null && other.Sublocality == null) || (Sublocality?.Equals(other.Sublocality) == true)) &&
                   ((Sublocality2 == null && other.Sublocality2 == null) || (Sublocality2?.Equals(other.Sublocality2) == true)) &&
                   ((Sublocality3 == null && other.Sublocality3 == null) || (Sublocality3?.Equals(other.Sublocality3) == true)) &&
                   ((AdministrativeDistrictLevel1 == null && other.AdministrativeDistrictLevel1 == null) || (AdministrativeDistrictLevel1?.Equals(other.AdministrativeDistrictLevel1) == true)) &&
                   ((AdministrativeDistrictLevel2 == null && other.AdministrativeDistrictLevel2 == null) || (AdministrativeDistrictLevel2?.Equals(other.AdministrativeDistrictLevel2) == true)) &&
                   ((AdministrativeDistrictLevel3 == null && other.AdministrativeDistrictLevel3 == null) || (AdministrativeDistrictLevel3?.Equals(other.AdministrativeDistrictLevel3) == true)) &&
                   ((PostalCode == null && other.PostalCode == null) || (PostalCode?.Equals(other.PostalCode) == true)) &&
                   ((Country == null && other.Country == null) || (Country?.Equals(other.Country) == true)) &&
                   ((FirstName == null && other.FirstName == null) || (FirstName?.Equals(other.FirstName) == true)) &&
                   ((LastName == null && other.LastName == null) || (LastName?.Equals(other.LastName) == true)) &&
                   ((Organization == null && other.Organization == null) || (Organization?.Equals(other.Organization) == true)));
        }
예제 #2
0
        public override int GetHashCode()
        {
            int hashCode = -1623438759;

            if (AddressLine1 != null)
            {
                hashCode += AddressLine1.GetHashCode();
            }

            if (AddressLine2 != null)
            {
                hashCode += AddressLine2.GetHashCode();
            }

            if (AddressLine3 != null)
            {
                hashCode += AddressLine3.GetHashCode();
            }

            if (Locality != null)
            {
                hashCode += Locality.GetHashCode();
            }

            if (Sublocality != null)
            {
                hashCode += Sublocality.GetHashCode();
            }

            if (Sublocality2 != null)
            {
                hashCode += Sublocality2.GetHashCode();
            }

            if (Sublocality3 != null)
            {
                hashCode += Sublocality3.GetHashCode();
            }

            if (AdministrativeDistrictLevel1 != null)
            {
                hashCode += AdministrativeDistrictLevel1.GetHashCode();
            }

            if (AdministrativeDistrictLevel2 != null)
            {
                hashCode += AdministrativeDistrictLevel2.GetHashCode();
            }

            if (AdministrativeDistrictLevel3 != null)
            {
                hashCode += AdministrativeDistrictLevel3.GetHashCode();
            }

            if (PostalCode != null)
            {
                hashCode += PostalCode.GetHashCode();
            }

            if (Country != null)
            {
                hashCode += Country.GetHashCode();
            }

            if (FirstName != null)
            {
                hashCode += FirstName.GetHashCode();
            }

            if (LastName != null)
            {
                hashCode += LastName.GetHashCode();
            }

            if (Organization != null)
            {
                hashCode += Organization.GetHashCode();
            }

            return(hashCode);
        }