コード例 #1
0
        public static void AddColumnGroup(IEnumerable <PropertyInfo> properties, TableFactory table)
        {
            var columnGroup = properties.Select(c => c.GetCustomAttributes(typeof(ExportableColumnGroupAttribute), false).FirstOrDefault()).ToList();

            if (columnGroup.FirstOrDefault(c => ((ExportableColumnGroupAttribute)c) != null) == null)
            {
                return;
            }

            table.AddRow();
            foreach (var prop in columnGroup.GroupBy(c => ((ExportableColumnGroupAttribute)c) == null ? null : ((ExportableColumnGroupAttribute)c).Description))
            {
                var style = properties.Select(c => c.GetCustomAttributes(typeof(ExportableColumnGroupAttribute), false)).SelectMany(c => c.Where(p => ((ExportableColumnGroupAttribute)p) != null && ((ExportableColumnGroupAttribute)p).Styles.Count() > 0)).Where(p => ((ExportableColumnGroupAttribute)p).Description == prop.Key);
                table.AddColumnGroup(prop.Key ?? "", prop.Count(), style.FirstOrDefault() != null ? ((ExportableColumnGroupAttribute)style.FirstOrDefault()).Styles : new string[] { });
            }
            table.EndRow();
        }