Exemple #1
0
        public void GetPropertyTest()
        {
            var props = CTRCHelper.GetPropertiesCache <PropertyTestModel>();

            foreach (var propertyInfo in props)
            {
                Console.WriteLine(propertyInfo.Name);
            }
            Assert.AreEqual(1, props.Length);
        }
Exemple #2
0
        /// <summary>
        /// Get the ExcelTitleAttribute on proerties
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static Dictionary <PropertyInfo, ExcelTitleAttribute> GetPropertiesAttributesDict <T>()
        {
            var dict         = new Dictionary <PropertyInfo, ExcelTitleAttribute>();
            int defaultOrder = 10000;

            foreach (var propertyInfo in CTRCHelper.GetPropertiesCache <T>())
            {
                var attrs = propertyInfo.GetCustomAttributes(true);
                var attr  = GetExcelTitleAttributeFromAttributes(attrs, defaultOrder++);

                if (attr == null)
                {
                    continue;
                }
                dict.Add(propertyInfo, attr);
            }

            return(dict);
        }