Esempio n. 1
0
 /// <summary>
 /// removes the next element(s) if any.
 /// </summary>
 internal void RemoveNext()
 {
     if (_next != null)
     {
         FrameCacheItem next = _next;
         _next          = null;
         next._previous = null;
         next._value    = null; //releasing the element just in case to avoid any risk of memory leak.
         next._uri      = null;
         next.RemoveNext();     //we remove all the next elements recursively.
     }
 }
Esempio n. 2
0
 internal FrameCacheItem GoForward()
 {
     if (CanGoForward)
     {
         _currentItem = _currentItem._next;
         return(_currentItem);
     }
     else
     {
         throw new InvalidOperationException("There are no entries in the forward navigation history.");
     }
 }
Esempio n. 3
0
            //note: I kept it because the algorithm might be useful when we will have figured out what CacheSize means.

            ///// <summary>
            ///// Adds the item to the cache, and handles the cases where:
            ///// - it is the first item,
            ///// - we add it to the end
            ///// - we add it somewhere else.
            ///// </summary>
            ///// <param name="next"></param>
            //internal void Add(object next, Uri uri)
            //{
            //    FrameCacheItem nextFrameCacheItem = new FrameCacheItem(next, uri);
            //    if (_currentItem != null)
            //    {
            //        int amountRemoved = _currentItem.RemoveNext();
            //        _currentItem._next = nextFrameCacheItem;
            //        nextFrameCacheItem._previous = _currentItem;
            //        _currentAmount -= amountRemoved - 1; //-1 because we added back the nextFrameCacheItem.
            //        if (_currentAmount > _cacheSize)
            //        {
            //            if (_cacheSize > 1) //would be stupid but not impossible
            //            {
            //                //we remove the first item of the list, and give its position as the first item to its next.
            //                FrameCacheItem oldFirst = firstItem;
            //                firstItem = firstItem._next;
            //                oldFirst._next = null;
            //                oldFirst._value = null;
            //                firstItem._previous = null;
            //            }
            //            else
            //            {
            //                firstItem = nextFrameCacheItem;
            //            }
            //            _currentAmount = _cacheSize;
            //        }
            //    }
            //    else //this is the first item in the cache:
            //    {
            //        firstItem = nextFrameCacheItem;
            //        ++_currentAmount;
            //    }
            //    _currentItem = nextFrameCacheItem;
            //}
            #endregion

            internal FrameCacheItem GoBack()
            {
                if (CanGoBack)
                {
                    _currentItem = _currentItem._previous;
                    return(_currentItem);
                }
                else
                {
                    throw new InvalidOperationException("There are no entries in the back navigation history.");
                }
            }
Esempio n. 4
0
            /// <summary>
            /// Adds the item to the cache, and handles the cases where:
            /// - it is the first item,
            /// - we add it to the end
            /// - we add it somewhere else.
            /// </summary>
            /// <param name="next"></param>
            /// <param name="uri"></param>
            internal void Add(object next, Uri uri)
            {
                FrameCacheItem nextFrameCacheItem = new FrameCacheItem(next, uri);

                if (_currentItem != null)
                {
                    _currentItem.RemoveNext(); //we remove any item that was after the current item.
                    //we set the new item as the next of the current one:
                    _currentItem._next           = nextFrameCacheItem;
                    nextFrameCacheItem._previous = _currentItem;
                }
                else //this is the first item in the cache:
                {
                    firstItem = nextFrameCacheItem;
                }
                //we set the new item as the current one.
                _currentItem = nextFrameCacheItem;
            }
Esempio n. 5
0
 internal void Clear()
 {
     firstItem.RemoveNext();
     firstItem = null;
 }