private void AddToSubgroups(object item, CollectionViewGroupInternal group, int level, bool loading) { var name = this.GetGroupName(item, group.GroupBy, level); if (name == UseAsItemDirectly) { if (loading) { group.Add(item); } else { var index = group.Insert(item, item, this.ActiveComparer); var num2 = group.LeafIndexFromItem(item, index); this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, num2)); } } else { var is2 = name as ICollection; if (is2 == null) { this.AddToSubgroup(item, group, level, name, loading); } else { foreach (var obj3 in is2) { this.AddToSubgroup(item, group, level, obj3, loading); } } } }
private void AddToSubgroup(object item, CollectionViewGroupInternal group, int level, object name, bool loading) { CollectionViewGroupInternal internal2; var num = this.IsDataInGroupOrder ? group.LastIndex : 0; var count = group.Items.Count; while (num < count) { internal2 = group.Items[num] as CollectionViewGroupInternal; if ((internal2 != null) && group.GroupBy.NamesMatch(internal2.Name, name)) { group.LastIndex = num; this.AddToSubgroups(item, internal2, level + 1, loading); return; } num++; } internal2 = new CollectionViewGroupInternal(name, group); this.InitializeGroup(internal2, level + 1); if (loading) { group.Add(internal2); group.LastIndex = num; } else { group.Insert(internal2, item, this.ActiveComparer); } this.AddToSubgroups(item, internal2, level + 1, loading); }