public static List <FeatureItemGroup> ConvertToGroup(this IEnumerable <FeatureItem> items) { var result = new List <FeatureItemGroup>(); foreach (var curItem in items) { var group = new FeatureItemGroup(); group.Add(curItem); result.Add(group); } return(result); }
public static List <FeatureItemGroup> GroupByFunction(this IEnumerable <FeatureItem> items, Func <FeatureItem, string> func, bool updateName = false) { var result = new List <FeatureItemGroup>(); var dic = items.GroupBy(m => func(m)).ToList(); foreach (var curItems in dic) { var group = new FeatureItemGroup(); group.AddRange(from item in curItems orderby item.Name select item); if (updateName) { group.DisplayName = func(curItems.First()); } result.Add(group); } return(result); }