Esempio n. 1
0
 private INode <T> FindExistingNodeByKey(TKey key)
 {
     return(RWLock.GetReadLock(_lock, LockTimeout, delegate
     {
         WeakReference value;
         return (INode <T>)(index.TryGetValue(key, out value) ? value.Target : null);
     }));
 }
Esempio n. 2
0
 private INode GetNode(TKey key)
 {
     return(RWLock.GetReadLock(_lock, _lockTimeout, delegate
     {
         WeakReference value;
         return (INode)(_index.TryGetValue(key, out value) ? value.Target : null);
     }));
 }
Esempio n. 3
0
 /// <summary>
 /// Gets the TValue with the specified key.
 /// </summary>
 /// <value></value>
 public virtual TValue this[TKey key]
 {
     get
     {
         return(RWLock.GetReadLock(
                    _dictLock,
                    RWLock.DEFAULT_RWLOCK_TIMEOUT,
                    () =>
         {
             TValue value;
             if (_dict.TryGetValue(key, out value))
             {
                 return value;
             }
             return default(TValue);
         }));
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Gets or sets the TValue with the specified key.
 /// </summary>
 /// <value></value>
 public TValue this[TKey key]
 {
     get
     {
         return(RWLock.GetReadLock(_lock, _lockTimeout, delegate
         {
             Node node;
             if (_data.TryGetValue(key, out node))
             {
                 DeleteNode(node);
                 InsertNode(node);
                 return node.Value;
             }
             return default(TValue);
         }));
     }
     set
     {
         Add(key, value);
     }
 }