public void Update(HorizonDesignator horizon) { // return on null if (horizon == null) { return; } HorizonDesignator entry = null; if (!Horizons.TryGetValue(horizon.ToString(), out entry)) { // key not found --> add new entry Horizons.Add(horizon.ToString(), new HorizonDesignator(horizon.Model, horizon.Lat, horizon.Lon, horizon.Height, horizon.Clearance, horizon.Horizon)); changed = true; } else { // key found --> check for update if (horizon.LastUpdated > entry.LastUpdated) { // new timestamp --> udpate all not empty fields entry.Model = horizon.Model; entry.Lat = horizon.Lat; entry.Lon = horizon.Lon; entry.Height = horizon.Height; entry.Clearance = horizon.Clearance; entry.LastUpdated = horizon.LastUpdated; changed = true; } } }
public HorizonDesignator Find(string model, double lat, double lon, double height, double clearance) { HorizonDesignator info = null; string search = new HorizonDesignator(model, lat, lon, height, clearance, null).ToString(); Horizons.TryGetValue(search, out info); return(info); }