private void AddToSubgroup(object item, CollectionViewGroupInternal group, int level, object name, bool loading) { int index = 0; for (int count = group.Items.Count; index < count; ++index) { CollectionViewGroupInternal group1 = group.Items[index] as CollectionViewGroupInternal; if (group1 != null && group.GroupBy.NamesMatch(group1.Name, name)) { group.LastIndex = index; this.AddToSubgroups(item, group1, level + 1, loading); return; } } CollectionViewGroupInternal group2 = new CollectionViewGroupInternal(name, group); this.InitializeGroup(group2, level + 1); if (loading) { group.Add((object)group2); group.LastIndex = index; } else { group.Insert((object)group2, item, this.ActiveComparer); } this.AddToSubgroups(item, group2, level + 1, loading); }
private void AddToSubgroups(object item, CollectionViewGroupInternal group, int level, bool loading) { object groupName = this.GetGroupName(item, group.GroupBy, level); if (groupName == CollectionViewGroupRoot.UseAsItemDirectly) { if (loading) { group.Add(item); } else { int index1 = group.Insert(item, item, this.ActiveComparer); int index2 = group.LeafIndexFromItem(item, index1); this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index2)); } } else { ICollection collection; if ((collection = groupName as ICollection) == null) { this.AddToSubgroup(item, group, level, groupName, loading); } else { foreach (object name in (IEnumerable)collection) { this.AddToSubgroup(item, group, level, name, loading); } } } }