public override bool ForGrouping(Grouping grouping) { PropertyGrouping <T> propertyGrouping = grouping as PropertyGrouping <T>; if (propertyGrouping == null) { return(false); } return(propertyGrouping.property == property); }
public List <PropertyGrouping> GetGrouped(Type type) { if (GroupedCache.ContainsKey(type)) { return(GroupedCache[type]); } List <CachedPropertyInfo> properties = GetOrdered(type); HashSet <PropertyInfo> used = new HashSet <PropertyInfo>(); List <PropertyGrouping> ret = new List <PropertyGrouping>(); Dictionary <string, PropertyGrouping> createdGroupings = new Dictionary <string, PropertyGrouping>(); foreach (var propInfo in properties) { CategoryAttribute grpAttr = null; if (propInfo.Property != null) { grpAttr = propInfo.Property.GetCustomAttribute <CategoryAttribute>(); } else { grpAttr = propInfo.Field.GetCustomAttribute <CategoryAttribute>(); } string catName = grpAttr != null ? grpAttr.Category : "Misc"; PropertyGrouping target = null; if (createdGroupings.ContainsKey(catName)) { target = createdGroupings[catName]; } else { target = new PropertyGrouping { GroupName = catName }; createdGroupings[catName] = target; ret.Add(target); } target.Properties.Add(propInfo); } // order by group name ret = ret.OrderBy((o) => o.GroupName).ToList(); GroupedCache[type] = ret; return(ret); }