Exemplo n.º 1
0
 // remove key / value pair if the given key exists and has expired
 private void CheckExpiration(TKey key)
 {
     if (LastAccessed.ContainsKey(key) && DateTime.Now - LastAccessed[key] > Timeout)
     {
         Remove(key);
     }
 }
Exemplo n.º 2
0
        public new bool ContainsKey(TKey key)
        {
            CheckExpiration(key);

            if (LastAccessed.ContainsKey(key))
            {
                LastAccessed[key] = DateTime.Now;
            }
            return(base.ContainsKey(key));
        }
Exemplo n.º 3
0
        public virtual new bool TryGetValue(TKey key, out TValue value)
        {
            CheckExpiration(key);

            if (LastAccessed.ContainsKey(key))
            {
                LastAccessed[key] = DateTime.Now;
            }
            return(base.TryGetValue(key, out value));
        }
Exemplo n.º 4
0
        public virtual new TValue this[TKey key] {
            get {
                CheckExpiration(key);

                if (LastAccessed.ContainsKey(key))
                {
                    LastAccessed[key] = DateTime.Now;
                }
                return(base[key]);
            }
            set {
                LastAccessed[key] = DateTime.Now;
                base[key]         = value;
            }
        }