System.Windows.Data.DataList.EnsureSnapShot C# (CSharp) Method

EnsureSnapShot() private method

private EnsureSnapShot ( ) : void
return void
        private void EnsureSnapShot()
        {
            if (_snapShot != null) {
                return;
            }

            ICollection sourceCollection = _sourceData as ICollection;
            int capacity = (sourceCollection != null) ? sourceCollection.Count : 16;

            _snapShot = new List<object>(capacity);
            if ((sourceCollection == null) || (sourceCollection.Count != 0)) {
                if (_predicate != null) {
                    foreach (object o in _sourceData) {
                        if (_predicate.Filter(o)) {
                            _snapShot.Add(o);
                        }
                    }
                }
                else {
                    foreach (object o in _sourceData) {
                        _snapShot.Add(o);
                    }
                }

                if (_comparer != null) {
                    _snapShot.Sort(_comparer);
                }
            }

            if (_currentIndex < 0) {
                _currentIndex = 0;
            }
            if (_currentIndex >= _snapShot.Count) {
                _currentIndex = _snapShot.Count - 1;
            }
        }