Esempio n. 1
0
        /// <summary>
        /// Returns true if Contact instances are equal
        /// </summary>
        /// <param name="other">Instance of Contact to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Contact other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     GivenName == other.GivenName ||
                     GivenName != null &&
                     GivenName.Equals(other.GivenName)
                 ) &&
                 (
                     Surname == other.Surname ||
                     Surname != null &&
                     Surname.Equals(other.Surname)
                 ) &&
                 (
                     OrganizationName == other.OrganizationName ||
                     OrganizationName != null &&
                     OrganizationName.Equals(other.OrganizationName)
                 ) &&
                 (
                     Role == other.Role ||
                     Role != null &&
                     Role.Equals(other.Role)
                 ) &&
                 (
                     Notes == other.Notes ||
                     Notes != null &&
                     Notes.Equals(other.Notes)
                 ) &&
                 (
                     EmailAddress == other.EmailAddress ||
                     EmailAddress != null &&
                     EmailAddress.Equals(other.EmailAddress)
                 ) &&
                 (
                     WorkPhoneNumber == other.WorkPhoneNumber ||
                     WorkPhoneNumber != null &&
                     WorkPhoneNumber.Equals(other.WorkPhoneNumber)
                 ) &&
                 (
                     MobilePhoneNumber == other.MobilePhoneNumber ||
                     MobilePhoneNumber != null &&
                     MobilePhoneNumber.Equals(other.MobilePhoneNumber)
                 ) &&
                 (
                     FaxPhoneNumber == other.FaxPhoneNumber ||
                     FaxPhoneNumber != null &&
                     FaxPhoneNumber.Equals(other.FaxPhoneNumber)
                 ) &&
                 (
                     Address1 == other.Address1 ||
                     Address1 != null &&
                     Address1.Equals(other.Address1)
                 ) &&
                 (
                     Address2 == other.Address2 ||
                     Address2 != null &&
                     Address2.Equals(other.Address2)
                 ) &&
                 (
                     City == other.City ||
                     City != null &&
                     City.Equals(other.City)
                 ) &&
                 (
                     Province == other.Province ||
                     Province != null &&
                     Province.Equals(other.Province)
                 ) &&
                 (
                     PostalCode == other.PostalCode ||
                     PostalCode != null &&
                     PostalCode.Equals(other.PostalCode)
                 ));
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                int hash = 41;
                // Suitable nullity checks

                hash = hash * 59 + Id.GetHashCode();

                if (GivenName != null)
                {
                    hash = hash * 59 + GivenName.GetHashCode();
                }

                if (Surname != null)
                {
                    hash = hash * 59 + Surname.GetHashCode();
                }

                if (OrganizationName != null)
                {
                    hash = hash * 59 + OrganizationName.GetHashCode();
                }

                if (Role != null)
                {
                    hash = hash * 59 + Role.GetHashCode();
                }

                if (Notes != null)
                {
                    hash = hash * 59 + Notes.GetHashCode();
                }

                if (EmailAddress != null)
                {
                    hash = hash * 59 + EmailAddress.GetHashCode();
                }

                if (WorkPhoneNumber != null)
                {
                    hash = hash * 59 + WorkPhoneNumber.GetHashCode();
                }

                if (MobilePhoneNumber != null)
                {
                    hash = hash * 59 + MobilePhoneNumber.GetHashCode();
                }

                if (FaxPhoneNumber != null)
                {
                    hash = hash * 59 + FaxPhoneNumber.GetHashCode();
                }

                if (Address1 != null)
                {
                    hash = hash * 59 + Address1.GetHashCode();
                }

                if (Address2 != null)
                {
                    hash = hash * 59 + Address2.GetHashCode();
                }

                if (City != null)
                {
                    hash = hash * 59 + City.GetHashCode();
                }

                if (Province != null)
                {
                    hash = hash * 59 + Province.GetHashCode();
                }

                if (PostalCode != null)
                {
                    hash = hash * 59 + PostalCode.GetHashCode();
                }

                return(hash);
            }
        }
 public bool Equals(WorkPhoneNumber other)
 {
     return(base.Equals(other) && string.Equals(Extension, other.Extension));
 }