using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IntelligentControlForsx.Code { public class UpdMemory { private readonly static ConcurrentDictionary _dic=new ConcurrentDictionary(); #region IDictionary 成员 public void Add(string key, T value) { _dic.TryAdd(key, value); } public bool ContainsKey(string key) { return _dic.ContainsKey(key); } public void AddorUpdate(string key, T value) { if (ContainsKey(key)) { this[key] = value; } else { _dic.TryAdd(key, value); } } public ICollection Keys { get { return _dic.Keys; } } public bool Remove(string key) { T val; return _dic.TryRemove(key, out val); } public bool TryGetValue(string key, out T value) { return _dic.TryGetValue(key, out value); } public ICollection Values { get { return _dic.Values; } } public T this[string key] { get { return _dic[key]; } set { _dic[key] = value; } } #endregion } }