Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Instantiates the static data fields for the class.
 /// </summary>
 static Values()
 {
     QSOUploadStatuses   = ADIFEnumeration.Get("QSOUploadStatus");
     QSOCompleteStatuses = ADIFEnumeration.Get("QSOCompleteStatus");
     Via                    = ADIFEnumeration.Get("Via");
     AntennaPaths           = ADIFEnumeration.Get("AntennaPath");
     QSLMediums             = ADIFEnumeration.Get("QSLMedium");
     Continents             = ADIFEnumeration.Get("Continent");
     EQSLSentStatuses       = ADIFEnumeration.Get("EQSLSentStatus");
     EQSLReceivedStatuses   = ADIFEnumeration.Get("EQSLReceivedStatus");
     PropagationModes       = ADIFEnumeration.Get("PropagationMode");
     ARRLSections           = ADIFEnumeration.Get("ARRLSection");
     Awards                 = ADIFEnumeration.Get("Award");
     Modes                  = ADIFEnumeration.Get("Mode");
     SponsoredAwardPrefixes = ADIFEnumeration.Get("SponsoredAwardPrefix");
     CountryCodes           = ADIFEnumeration.Get("Countries");
     Contests               = ADIFEnumeration.Get("ContestID");
     Bands                  = ADIFEnumeration.Get("Band");
     Credits                = ADIFEnumeration.Get("Credit");
 }