using System.Collections.Generic; using Com.ForbiddenByte.OSA.DataHelpers; using Com.ForbiddenByte.OSA.Core; namespace Extensions.Unity.OSA.DataProvider { public class SimpleDataProvider : SimpleDataHelper { public SimpleDataProvider(IOSA iAdapter, bool keepVelocityOnCountChange = true) : base(iAdapter, keepVelocityOnCountChange) { } public virtual void RefreshData(IList items) { if (items == null) { if (Count > 0) RemoveItems(0, Count); return; } if (IsNewData(items)) { if (Count > 0) RemoveItems(0, Count); if (items != null) InsertItems(0, items); } } bool IsNewData(IList items) { if (Count != items.Count) return true; for (int i = 0; i < Count; i++) if (!this[i].Equals(items[i])) return true; return false; } } }