public static AircraftModel GetByICAO(string icao)
        {
            try
            {
                if (list == null)
                {
                    string jsonstring = ResourceHelper.LoadExternalResource(resourceFileName);
                    list = JsonConvert.DeserializeObject <IDictionary <string, IDictionary <string, string> > >(jsonstring);
                    LoggingHelper.LogBehavior($">>> Done converting {resourceFileName} file ''.");
                }

                string name = String.Empty;

                if (String.IsNullOrEmpty(icao))
                {
                    icao = string.Empty;
                }

                var nameReg = list.Keys.Where(s => icao.StartsWith(s)).FirstOrDefault();
                nameReg = (String.IsNullOrEmpty(nameReg)) ? "" : nameReg;

                AircraftModel model = new AircraftModel();
                model.ICAO    = icao;
                model.IsValid = false;

                if (list.ContainsKey(nameReg))
                {
                    model.Name    = list[nameReg]["Name"];
                    model.Type    = list[nameReg].ContainsKey("Type") ? (AircraftCategory)System.Enum.Parse(typeof(AircraftCategory), list[nameReg]["Type"]) : AircraftCategory.NoModel;
                    model.IsValid = true;

                    if (model.Type == AircraftCategory.NoModel)
                    {
                        model.Type = AircraftCategory.AirplaneLow;
                    }
                }
                else
                {
                    model.Name = model.ICAO;
                }

                return(model);
            }
            catch (Exception e)
            {
                throw new ArgumentException(resourceFileName, e);
            }
        }
        public Airplane(string hexCode, string flightName, AltitudeMetric altitude, double latitude, double longitude, SpeedMetric speed, double verticalSpeed, double direction, string from, string to, string model, string registration, bool isOnGround)
        {
            var airplaneDatabaseData = AircraftDatabase.GetByICAO(hexCode);

            this.ID    = hexCode;
            this.Model = airplaneDatabaseData != null?AircraftModel.GetByICAO(airplaneDatabaseData.AircraftModelName) : null;

            this.Direction      = direction;
            this.From           = Airport.GetAirportByIata(from);
            this.Name           = flightName.Trim();
            this.Airline        = Airline.GetAirlineByFlight(flightName);
            this.Position       = new GeoPosition(latitude, longitude, altitude);
            this.Registration   = new AircraftRegistration(registration);
            this.Speed          = speed;
            this.To             = Airport.GetAirportByIata(to);
            this.VerticalSpeed  = verticalSpeed;
            this.DateCreation   = DateTime.Now;
            this.IsOnGround     = isOnGround;
            this.DateExpiration = DateTime.Now.AddHours(1);
        }