public override void Promote(FrugalListBase <T> oldList) { for (int index = 0; index < oldList.Count; ++index) { if (this.Add(oldList.EntryAt(index)) != FrugalListStoreState.Success) { throw new ArgumentException(string.Format("FrugalList_TargetMapCannotHoldAllData", new object[3] { (object)oldList.ToString(), (object)this.ToString(), (object)nameof(oldList) })); } } }
public int Add(T value) { if (this._listStore == null) { this._listStore = (FrugalListBase <T>) new SingleItemList <T>(); } FrugalListStoreState frugalListStoreState = this._listStore.Add(value); if (frugalListStoreState != FrugalListStoreState.Success) { if (FrugalListStoreState.ThreeItemList == frugalListStoreState) { ThreeItemList <T> threeItemList = new ThreeItemList <T>(); threeItemList.Promote(this._listStore); int num = (int)threeItemList.Add(value); this._listStore = (FrugalListBase <T>)threeItemList; } else if (FrugalListStoreState.SixItemList == frugalListStoreState) { SixItemList <T> sixItemList = new SixItemList <T>(); sixItemList.Promote(this._listStore); this._listStore = (FrugalListBase <T>)sixItemList; int num = (int)sixItemList.Add(value); this._listStore = (FrugalListBase <T>)sixItemList; } else { if (FrugalListStoreState.Array != frugalListStoreState) { throw new InvalidOperationException("FrugalList_CannotPromoteBeyondArray"); } ArrayItemList <T> arrayItemList = new ArrayItemList <T>(this._listStore.Count + 1); arrayItemList.Promote(this._listStore); this._listStore = (FrugalListBase <T>)arrayItemList; int num = (int)arrayItemList.Add(value); this._listStore = (FrugalListBase <T>)arrayItemList; } } return(this._listStore.Count - 1); }