public virtual void Set(TKey key, TValue value) { lock (Lock) if (DictionaryKesh.ContainsKey(key)) { DictionaryKesh[key] = value; } else { DictionaryKesh.Add(key, value); } }
public virtual void Set(IEnumerable <KeyValuePair <TKey, TValue> > items) { lock (Lock) { _key = default(TKey); _value = default(TValue); if (items != null) { foreach (var item in items) { DictionaryKesh.Add(item.Key, item.Value); } } } }
public override TValue Get(string key) { var lckey = key?.ToLower(); if (lckey == null) { return(default(TValue)); } if (object.Equals(lckey, _key)) { return(_value); } TValue v; if (DictionaryKesh.TryGetValue(lckey, out v)) { _key = lckey; _value = v; return(v); } lock (Lock) { if (DictionaryKesh.TryGetValue(lckey, out v)) { _key = lckey; _value = v; return(v); } var value = GetValueByKey(key); DictionaryKeshAddNoLock(lckey, value); _key = key; _value = value; return(value); } }
public virtual void Clear() { lock (Lock) DictionaryKesh.Clear(); }
public virtual bool Contains(TKey key) { lock (Lock) return(DictionaryKesh.ContainsKey(key)); }