/// <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 (DateTime != null) { hashCode = hashCode * 59 + DateTime.GetHashCode(); } if (Temperature != null) { hashCode = hashCode * 59 + Temperature.GetHashCode(); } if (AirHumidity != null) { hashCode = hashCode * 59 + AirHumidity.GetHashCode(); } if (CarbonMonoxide != null) { hashCode = hashCode * 59 + CarbonMonoxide.GetHashCode(); } if (HealthStatus != null) { hashCode = hashCode * 59 + HealthStatus.GetHashCode(); } return(hashCode); } }
public static SamplingItem CreateSamplingItem(string SamplingItemType) { SamplingItem item; if (SamplingItemType == "Opacity") { return(item = new Opacity()); } else if (SamplingItemType == "SulfurDioxide") { return(item = new SulfurDioxide()); } else if (SamplingItemType == "NitrogenOxides") { return(item = new NitrogenOxides()); } else if (SamplingItemType == "CarbonMonoxide") { return(item = new CarbonMonoxide()); } else if (SamplingItemType == "TotalReducedSulfur") { return(item = new TotalReducedSulfur()); } else if (SamplingItemType == "HydrogenChloride") { return(item = new HydrogenChloride()); } else if (SamplingItemType == "VolatileOrganicLiquid") { return(item = new VolatileOrganicLiquid()); } else if (SamplingItemType == "Oxygen") { return(item = new Oxygen()); } else if (SamplingItemType == "FlowRate") { return(item = new FlowRate()); } else if (SamplingItemType == "Temperature") { return(item = new Temperature()); } else { return(null); } // TODO: Fatory Pattern by C# Reflection with .NET Standard 2.0 }
/// <summary> /// Returns true if Reading instances are equal /// </summary> /// <param name="other">Instance of Reading to be compared</param> /// <returns>Boolean</returns> public bool Equals(Reading other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( DateTime == other.DateTime || DateTime != null && DateTime.Equals(other.DateTime) ) && ( Temperature == other.Temperature || Temperature != null && Temperature.Equals(other.Temperature) ) && ( AirHumidity == other.AirHumidity || AirHumidity != null && AirHumidity.Equals(other.AirHumidity) ) && ( CarbonMonoxide == other.CarbonMonoxide || CarbonMonoxide != null && CarbonMonoxide.Equals(other.CarbonMonoxide) ) && ( HealthStatus == other.HealthStatus || HealthStatus != null && HealthStatus.Equals(other.HealthStatus) )); }