// *** Protected Methods *** protected void PostUpdate(DataListUpdate update) { foreach (IUpdatableCollection collection in updateSubscriptions) { collection.Update(update); } }
private void Update_Add(DataListUpdate update) { // If the entire update is outside of the visible collection then ignore it if (update.Index > currentCount) { return; } currentCount += update.Count; base.OnItemsAdded(update.Index, update.Count); }
private void Update_Remove(DataListUpdate update) { // If the entire update is outside of the visible collection then ignore it if (update.Index >= currentCount) { return; } // If the update overlaps the boundary of the visible collection then only remove visible items int removedItemCount = Math.Min(update.Count, currentCount - update.Index); currentCount -= removedItemCount; base.OnItemsRemoved(update.Index, removedItemCount); }
// *** IUpdatableCollection Members *** void IUpdatableCollection.Update(DataListUpdate update) { switch (update.Action) { case DataListUpdateAction.Add: base.OnItemsAdded(update.Index, update.Count); break; case DataListUpdateAction.Remove: base.OnItemsRemoved(update.Index, update.Count); break; case DataListUpdateAction.Reset: base.Reset(); break; } }
// *** IUpdatableCollection Members *** void IUpdatableCollection.Update(DataListUpdate update) { switch (update.Action) { case DataListUpdateAction.Add: Update_Add(update); break; case DataListUpdateAction.Remove: Update_Remove(update); break; case DataListUpdateAction.Reset: Update_Reset(); break; } }