Пример #1
0
 /// <summary>
 /// Add one record to the database
 /// </summary>
 /// <param name="rec">A new record to add</param>
 public string Add(icaoRec rec)
 {
     if (rec != null)
     {
         if (rec.Icao == "children")
         {
             return("");                  // get rid of special element
         }
         char dbPrefix = rec.Icao[0];
         return(m_db[dbIndex(dbPrefix)].Add(rec));
     }
     return("");
 }
Пример #2
0
        /// <summary>
        /// Returns a new Icao Record from given Jason
        /// </summary>
        /// <param name="js">The record as Jason fragment</param>
        private static icaoRec FromNative(string js)
        {
            JsonRecord jRec = JsonParser.Decompose(js);

            if (jRec?.Count > 0)
            {
                var reg  = !jRec.Values[0].ContainsKey("r") ? "" : jRec.Values[0]["r"];
                var typ  = !jRec.Values[0].ContainsKey("t") ? "" : jRec.Values[0]["t"];
                var iRec = new icaoRec(jRec.Keys[0].ToUpperInvariant(), reg, typ);
                return(iRec);
            }
            else
            {
                return(new icaoRec("", "", ""));
            }
        }