Esempio n. 1
0
        /// <summary>
        ///     Versioning is not currently implemented
        ///     Return the list of fields for a given API Class
        /// </summary>
        /// <param name="APIversion">Set to 0 (== "best")</param>
        /// <param name="t">The class type for which to get the fields</param>
        /// <returns>List of field names for the given API version</returns>
        public static List <string> GetContentFields(int APIversion, Type t)
        {
            var fields = new List <string>();

            var recommendedApiVersion = AApiVersionedFields.getRecommendedApiVersion(t);
            //Could be zero if no "recommendedApiVersion" const field
            var ap = t.GetProperties();

            foreach (var m in ap)
            {
                if (AApiVersionedFields.banlist.Contains(m.Name))
                {
                    continue;
                }
                if (!AApiVersionedFields.checkVersion(t, m.Name, APIversion == 0 ? recommendedApiVersion : APIversion))
                {
                    continue;
                }

                fields.Add(m.Name);
            }
            fields.Sort(new PriorityComparer(t));

            return(fields);
        }
Esempio n. 2
0
        /// <summary>
        ///     Gets a lookup table from fieldname to type.
        /// </summary>
        /// <param name="APIversion">Version of API to use</param>
        /// <param name="t">API data type to query</param>
        /// <returns></returns>
        public static Dictionary <string, Type> GetContentFieldTypes(int APIversion, Type t)
        {
            var types = new Dictionary <string, Type>();

            var recommendedApiVersion = AApiVersionedFields.getRecommendedApiVersion(t);
            //Could be zero if no "recommendedApiVersion" const field
            var ap = t.GetProperties();

            foreach (var m in ap)
            {
                if (AApiVersionedFields.banlist.Contains(m.Name))
                {
                    continue;
                }
                if (!AApiVersionedFields.checkVersion(t, m.Name, APIversion == 0 ? recommendedApiVersion : APIversion))
                {
                    continue;
                }

                types.Add(m.Name, m.PropertyType);
            }

            return(types);
        }