Esempio n. 1
0
        private IVirtualChangeSet <TObject, TKey> Virtualise(ISortedChangeSet <TObject, TKey> updates = null)
        {
            if (_isLoaded == false)
            {
                return(null);
            }

            var previous   = _current;
            var virualised = _all.Skip(_parameters.StartIndex)
                             .Take(_parameters.Size)
                             .ToList();

            _current = new KeyValueCollection <TObject, TKey>(virualised, _all.Comparer, updates?.SortedItems.SortReason ?? SortReason.DataChanged, _all.Optimisations);

            ////check for changes within the current virtualised page.  Notify if there have been changes or if the overall count has changed
            var notifications = _changedCalculator.Calculate(_current, previous, updates);

            if (notifications.Count == 0 && (previous.Count != _current.Count))
            {
                return(null);
            }

            var response = new VirtualResponse(_parameters.Size, _parameters.StartIndex, _all.Count);

            return(new VirtualChangeSet <TObject, TKey>(notifications, _current, response));
        }
 private VirtualChangeSet()
 {
     SortedItems = new KeyValueCollection <TObject, TKey>();
     Response    = new VirtualResponse(0, 0, 0);
 }