private void UpdatePage(int page, IList <T> results, uint stateWhenRequested) { if (stateWhenRequested != _state) { // this request may contain out-of-date data, so ignore it return; } bool stillRelevant = _requestedPages.Remove(page); if (!stillRelevant) { return; } _fetchedPages.Add(page); var startIndex = page * _pageSize; var count = Math.Min(results.Count, _pageSize); for (int i = 0; i < count; i++) { var index = startIndex + i; var virtualItem = _virtualItems[index] ?? (_virtualItems[index] = new VirtualItem <T>(this, index)); if (virtualItem.Item == null || results[i] == null || !_equalityComparer.Equals(virtualItem.Item, results[i])) { virtualItem.SupplyValue(results[i]); } } if (results.Count > 0) { OnItemsRealized(new ItemsRealizedEventArgs(startIndex, results.Count)); } }
public VirtualItem <T> this[int index] { get { RealizeItemRequested(index); return(_virtualItems[index] ?? (_virtualItems[index] = new VirtualItem <T>(this, index))); } set { throw new NotImplementedException(); } }
public VirtualItem <T> this[int index] { get { if (index >= Count) { throw new ArgumentOutOfRangeException("index"); } RealizeItemRequested(index); return(_virtualItems[index] ?? (_virtualItems[index] = new VirtualItem <T>(this, index))); } set { throw new NotImplementedException(); } }
public void Insert(int index, VirtualItem <T> item) { throw new NotImplementedException(); }
public bool Remove(VirtualItem <T> item) { throw new NotImplementedException(); }
public void Add(VirtualItem <T> item) { throw new NotImplementedException(); }
public bool Contains(VirtualItem <T> item) { return(item.Parent == this); }
public int IndexOf(VirtualItem <T> item) { return(item.Index); }