/// <inheritdoc /> protected bool Equals(Orbit other) { return(MeanAnomoly.Equals(other.MeanAnomoly) && AscendingNode.Equals(other.AscendingNode) && ArgumentPerigee.Equals(other.ArgumentPerigee) && MeanMotion.Equals(other.MeanMotion) && RecoveredSemiMajorAxis.Equals(other.RecoveredSemiMajorAxis) && RecoveredMeanMotion.Equals(other.RecoveredMeanMotion) && Perigee.Equals(other.Perigee) && Apogee.Equals(other.Apogee) && Period.Equals(other.Period) && Epoch.Equals(other.Epoch) && BStar.Equals(other.BStar) && Eccentricity.Equals(other.Eccentricity) && Inclination.Equals(other.Inclination)); }
public void Perigee() { //Deserialize using (StreamReader streamReader = new StreamReader("CelestialData\\Perigee.txt")) { BinaryFormatter binaryFormatter = new BinaryFormatter(); Perigee ev = (Perigee)binaryFormatter.Deserialize(streamReader.BaseStream); PerigeeApogee lE1 = ev.LastPerigee; PerigeeApogee nE1 = ev.NextPerigee; PerigeeApogee lE2 = data.Perigee.LastPerigee; PerigeeApogee nE2 = data.Perigee.NextPerigee; PropertyInfo[] properties = typeof(PerigeeApogee).GetProperties(); foreach (PropertyInfo property in properties) { var l1 = property.GetValue(lE1); var l2 = property.GetValue(lE2); var n1 = property.GetValue(nE1); var n2 = property.GetValue(nE2); Assert.AreEqual(l1.ToString(), l2.ToString(), $"Last Perigee: {l2} not expected."); if (l1.GetType() == typeof(Distance) && l2.GetType() == typeof(Distance)) { PropertyInfo[] propertiesSub = typeof(Distance).GetProperties(); foreach (PropertyInfo propertySub in propertiesSub) { var l1Sub = propertySub.GetValue(l1); var l2Sub = propertySub.GetValue(l2); Assert.AreEqual(l1Sub.ToString(), l2Sub.ToString(), $"Last Perigee {propertySub.Name}: {l2Sub} not expected."); } } Assert.AreEqual(n1.ToString(), n2.ToString(), $"Next Perigee: {n2} not expected."); if (n1.GetType() == typeof(Distance) && n2.GetType() == typeof(Distance)) { PropertyInfo[] propertiesSub = typeof(Distance).GetProperties(); foreach (PropertyInfo propertySub in propertiesSub) { var n1Sub = propertySub.GetValue(n1); var n2Sub = propertySub.GetValue(n2); Assert.AreEqual(n1Sub.ToString(), n2Sub.ToString(), $"Next Perigee {propertySub.Name}: {n2Sub} not expected."); } } } } }
/// <inheritdoc /> public override int GetHashCode() { unchecked { var hashCode = MeanAnomoly.GetHashCode(); hashCode = (hashCode * 397) ^ AscendingNode.GetHashCode(); hashCode = (hashCode * 397) ^ ArgumentPerigee.GetHashCode(); hashCode = (hashCode * 397) ^ MeanMotion.GetHashCode(); hashCode = (hashCode * 397) ^ RecoveredSemiMajorAxis.GetHashCode(); hashCode = (hashCode * 397) ^ RecoveredMeanMotion.GetHashCode(); hashCode = (hashCode * 397) ^ Perigee.GetHashCode(); hashCode = (hashCode * 397) ^ Apogee.GetHashCode(); hashCode = (hashCode * 397) ^ Period.GetHashCode(); hashCode = (hashCode * 397) ^ Epoch.GetHashCode(); hashCode = (hashCode * 397) ^ BStar.GetHashCode(); hashCode = (hashCode * 397) ^ Eccentricity.GetHashCode(); hashCode = (hashCode * 397) ^ Inclination.GetHashCode(); return(hashCode); } }
public bool Check_Perigee() { IFormatter formatter = new BinaryFormatter(); //Deserialize using (StreamReader streamReader = new StreamReader("CelestialData\\Perigee.txt")) { BinaryFormatter binaryFormatter = new BinaryFormatter(); Perigee ev = (Perigee)binaryFormatter.Deserialize(streamReader.BaseStream); PerigeeApogee lE1 = ev.LastPerigee; PerigeeApogee nE1 = ev.NextPerigee; PerigeeApogee lE2 = this.Perigee.LastPerigee; PerigeeApogee nE2 = this.Perigee.NextPerigee; PropertyInfo[] properties = typeof(PerigeeApogee).GetProperties(); foreach (PropertyInfo property in properties) { var l1 = property.GetValue(lE1); var l2 = property.GetValue(lE2); var n1 = property.GetValue(nE1); var n2 = property.GetValue(nE2); if (l1.ToString() != l2.ToString()) { return(false); } if (l1.GetType() == typeof(Distance) && l2.GetType() == typeof(Distance)) { PropertyInfo[] propertiesSub = typeof(Distance).GetProperties(); foreach (PropertyInfo propertySub in propertiesSub) { var l1Sub = propertySub.GetValue(l1); var l2Sub = propertySub.GetValue(l2); if (l1Sub.ToString() != l2Sub.ToString()) { return(false); } } } if (n1.ToString() != n2.ToString()) { return(false); } if (n1.GetType() == typeof(Distance) && n2.GetType() == typeof(Distance)) { PropertyInfo[] propertiesSub = typeof(Distance).GetProperties(); foreach (PropertyInfo propertySub in propertiesSub) { var n1Sub = propertySub.GetValue(n1); var n2Sub = propertySub.GetValue(n2); if (n1Sub.ToString() != n2Sub.ToString()) { return(false); } } } } } return(true); }