public void AddData(GpsData data) { if (VerifyInput(data)) { gpsData.Add(data); } }
private bool VerifyInput(GpsData data) { if (typeof(GpsDataTimeLocation).IsAssignableFrom(data.GetType())) { GpsDataTimeLocation d1 = (GpsDataTimeLocation)data; if (!d1.Latitude.Equals(latitude) || !d1.Longitude.Equals(this.longitude) || d1.Time != this.time) { throw new Exception("Bogus data to GpsPoint./n" + data.ToString()); } if (typeof(GpsDataDate).IsAssignableFrom(data.GetType())) { GpsDataDate d2 = (GpsDataDate)data; if (this.date != 0 && d2.Date != this.date) { throw new Exception("Bogus data for date to GpsPoint./n" + data.ToString()); } } } return(true); }