Exemple #1
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (CostCentre != null)
         {
             hashCode = hashCode * 59 + CostCentre.GetHashCode();
         }
         if (StaffGroups != null)
         {
             hashCode = hashCode * 59 + StaffGroups.GetHashCode();
         }
         if (Children != null)
         {
             hashCode = hashCode * 59 + Children.GetHashCode();
         }
         return(hashCode);
     }
 }
Exemple #2
0
        /// <summary>
        /// Returns true if Unit instances are equal
        /// </summary>
        /// <param name="other">Instance of Unit to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Unit other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     CostCentre == other.CostCentre ||
                     CostCentre != null &&
                     CostCentre.Equals(other.CostCentre)
                 ) &&
                 (
                     StaffGroups == other.StaffGroups ||
                     StaffGroups != null &&
                     other.StaffGroups != null &&
                     StaffGroups.SequenceEqual(other.StaffGroups)
                 ) &&
                 (
                     Children == other.Children ||
                     Children != null &&
                     other.Children != null &&
                     Children.SequenceEqual(other.Children)
                 ));
        }