コード例 #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 (CpuCores != null)
                {
                    hashCode = hashCode * 59 + CpuCores.GetHashCode();
                }

                if (Preemptible != null)
                {
                    hashCode = hashCode * 59 + Preemptible.GetHashCode();
                }

                if (RamGb != null)
                {
                    hashCode = hashCode * 59 + RamGb.GetHashCode();
                }

                if (DiskGb != null)
                {
                    hashCode = hashCode * 59 + DiskGb.GetHashCode();
                }

                if (Zones != null)
                {
                    hashCode = hashCode * 59 + Zones.GetHashCode();
                }

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

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     CpuCores == other.CpuCores ||
                     CpuCores != null &&
                     CpuCores.Equals(other.CpuCores)
                     ) &&
                 (
                     Preemptible == other.Preemptible ||
                     Preemptible != null &&
                     Preemptible.Equals(other.Preemptible)
                 ) &&
                 (
                     RamGb == other.RamGb ||
                     RamGb != null &&
                     RamGb.Equals(other.RamGb)
                 ) &&
                 (
                     DiskGb == other.DiskGb ||
                     DiskGb != null &&
                     DiskGb.Equals(other.DiskGb)
                 ) &&
                 (
                     Zones == other.Zones ||
                     Zones != null &&
                     Zones.SequenceEqual(other.Zones)
                 ));
        }