/// <summary> /// Retrieves an ADIF enumeration by type. /// </summary> /// <param name="type">The enumeration type to retrieve.</param> public static ADIFEnumeration Get(string type) { if (string.IsNullOrEmpty(type)) { throw new ArgumentException("Enumeration type is required.", nameof(type)); } var enumeration = new ADIFEnumeration(type); var query = string.Empty; if (type == "Countries") { query = RETRIEVE_COUNTRY_CODES_SQL; } else if (type == "Band") { if (Values.ITU <= 0) { Values.ITU = 2; } query = RETRIEVE_BANDS_SQL.Replace("{{ITU}}", Values.ITU.ToString()); } else if (type == "Credit") { query = RETRIEVE_CREDIT_SQL; } else { query = ENUM_RETRIEVE_SQL.Replace("{{TYPE}}", type.Replace("'", "''")); } var data = SQLiteHelper.Instance.ReadData(query); foreach (dynamic d in data) { var enumVal = new ADIFEnumerationValue(d); if (!string.IsNullOrEmpty(enumVal.Code)) { enumeration.Add(enumVal); } } return(enumeration.Count > 0 ? enumeration : null); }
/// <summary> /// Creates an ADIF enumeration using the custom options in a user-defined tag. /// </summary> /// <param name="tag">User-defined tag from which to derive the enumeration.</param> public static ADIFEnumeration FromUserDefinedTag(UserDefTag tag) { if (tag == null) { throw new ArgumentNullException(nameof(tag), "User-defined tag is required."); } if (tag.CustomOptions != null) { var enumVal = new ADIFEnumeration(tag.FieldName); foreach (var option in tag.CustomOptions) { enumVal.Add(new ADIFEnumerationValue(option)); } return(enumVal); } return(null); }