private int CreateAutomaticSubtotals(AutomaticSubtotalContext context, DataMemberList members, bool isColumn) { int num = 0; for (int i = 0; i < members.Count; i++) { DataMember dataMember = members[i]; if (dataMember.Subtotal) { context.CurrentIndex = context.StartIndex; if (isColumn) { foreach (CellList cellList in context.CellLists) { cellList.Clear(); } } else { context.Rows.Clear(); } base.BuildAndSetupAxisScopeTreeForAutoSubtotals(ref context, dataMember); DataMember dataMember2 = (DataMember)dataMember.PublishClone(context, null, true); context.AdjustReferences(); dataMember2.IsAutoSubtotal = true; dataMember2.Subtotal = false; members.Insert(i + 1, dataMember2); num = context.CurrentIndex - context.StartIndex; if (isColumn) { int num2 = 0; while (i < this.m_dataRows.Count) { this.m_dataRows[num2].Cells.InsertRange(context.CurrentIndex, context.CellLists[num2]); num2++; } base.m_columnCount += num; } else { this.m_dataRows.InsertRange(context.CurrentIndex, context.Rows); base.m_rowCount += num; } if (dataMember.SubMembers != null) { context.CurrentScope = dataMember.Grouping.Name; context.CurrentDataScope = dataMember; int num3 = this.CreateAutomaticSubtotals(context, dataMember.SubMembers, isColumn); if (isColumn) { dataMember.ColSpan += num3; } else { dataMember.RowSpan += num3; } num += num3; } else { context.StartIndex++; } } else if (dataMember.SubMembers != null) { if (dataMember.Grouping != null) { context.CurrentScope = dataMember.Grouping.Name; context.CurrentDataScope = dataMember; } int num4 = this.CreateAutomaticSubtotals(context, dataMember.SubMembers, isColumn); if (isColumn) { dataMember.ColSpan += num4; } else { dataMember.RowSpan += num4; } num += num4; } else { context.StartIndex++; } } return(num); }