public void CopyTo(KeyValuePair <TKey, TValue>[] array, int arrayIndex)
 {
     using (ReadOnlyLock readOnlyLock = new ReadOnlyLock(this.readerWriterLockSlim_0))
     {
         this.dict.CopyTo(array, arrayIndex);
     }
 }
Ejemplo n.º 2
0
        public IEnumerator <TValue> GetEnumerator()
        {
            ReadOnlyLock readLock = new ReadOnlyLock(_rwl, _timeout);

            if (!readLock.IsLockAcquired)
            {
                return((new List <TValue>()).GetEnumerator());
            }
            return(new SynchronizedEnumerator <TValue>(_dict.Values.GetEnumerator(), readLock));
        }
        public bool TryGetValue(TKey key, out TValue value)
        {
            bool flag;

            using (ReadOnlyLock readOnlyLock = new ReadOnlyLock(this.readerWriterLockSlim_0))
            {
                flag = this.dict.TryGetValue(key, out value);
            }
            return(flag);
        }
        public bool ContainsKey(TKey key)
        {
            bool flag;

            using (ReadOnlyLock readOnlyLock = new ReadOnlyLock(this.readerWriterLockSlim_0))
            {
                flag = this.dict.ContainsKey(key);
            }
            return(flag);
        }
        public bool Contains(KeyValuePair <TKey, TValue> item)
        {
            bool flag;

            using (ReadOnlyLock readOnlyLock = new ReadOnlyLock(this.readerWriterLockSlim_0))
            {
                flag = this.dict.Contains(item);
            }
            return(flag);
        }
 public virtual TValue this[TKey key]
 {
     get
     {
         TValue item;
         using (ReadOnlyLock readOnlyLock = new ReadOnlyLock(this.readerWriterLockSlim_0))
         {
             item = this.dict[key];
         }
         return(item);
     }
     set
     {
         using (ReadLock readLock = new ReadLock(this.readerWriterLockSlim_0))
         {
             this.dict[key] = value;
         }
     }
 }
Ejemplo n.º 7
0
 public TValue this[TKey key]
 {
     get
     {
         using (ReadOnlyLock readLock = new ReadOnlyLock(_rwl, _timeout))
         {
             if (!readLock.IsLockAcquired)
             {
                 return(default(TValue));
             }
             TValue value;
             _dict.TryGetValue(key, out value);
             return(value);
         }
     }
     set
     {
         Add(new KeyValuePair <TKey, TValue>(key, value));
     }
 }
 public SynchronizedEnumerator(IEnumerator <T> enumerator, ReadOnlyLock l)
     : base(enumerator)
 {
     _lock = l;
 }