コード例 #1
0
        /// <summary>
        /// Returns true if Owner instances are equal
        /// </summary>
        /// <param name="other">Instance of Owner to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OwnerViewModel other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     OwnerCode == other.OwnerCode ||
                     OwnerCode != null &&
                     OwnerCode.Equals(other.OwnerCode)
                 ) &&
                 (
                     OrganizationName == other.OrganizationName ||
                     OrganizationName != null &&
                     OrganizationName.Equals(other.OrganizationName)
                 ) &&
                 (
                     LocalAreaName == other.LocalAreaName ||
                     LocalAreaName != null &&
                     LocalAreaName.Equals(other.LocalAreaName)
                 ) &&
                 (
                     PrimaryContactName == other.PrimaryContactName ||
                     PrimaryContactName != null &&
                     PrimaryContactName.Equals(other.PrimaryContactName)
                 ) &&
                 (
                     EquipmentCount == other.EquipmentCount ||
                     EquipmentCount.Equals(other.EquipmentCount)
                 ) &&
                 (
                     Status == other.Status ||
                     Status != null &&
                     Status.Equals(other.Status)
                 ));
        }
コード例 #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 (OwnerCode != null)
                {
                    hash = hash * 59 + OwnerCode.GetHashCode();
                }

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

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

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

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

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

                return(hash);
            }
        }