protected override void OnReset(IReadOnlyList <TSource> newItems) { _resetting = true; try { for (int i = SourceLists.Count - 1; i >= 0; --i) { RemoveSourceCollection(i); } for (int i = 0; i < newItems.Count; ++i) { var list = _selector.Invoke(newItems[i]); AddSourceCollection(i, (list as IReadOnlyList <TResult>) ?? list.ToArray(), false); } _listInfo.Clear(); var lastInfo = new ListInfo(0, 0); foreach (var list in SourceLists) { var info = new ListInfo(lastInfo.Offset + lastInfo.Count, list.Count); _listInfo.Add(info); lastInfo = info; } _listInfo.Add(new ListInfo(lastInfo.Offset + lastInfo.Count, 0)); ResultList.Reset(SourceLists.SelectMany(s => s)); } finally { _resetting = false; } }
/// <summary> /// Checks SourceLists for a given list and returns it if found. Otherwise, returns null /// </summary> public Dictionary <string, SourceListItem> GetSourceListForKey(string key) { if (string.IsNullOrEmpty(key) || !SourceLists.ContainsKey(key)) { return(null); } return(SourceLists[key]); }
public MockContactGeneratorHelper() { RandomHelper = new RandomHelper(); SourceLists = new SourceLists(); }