public override object this[object key] { set { data[DictOps.NullToObj(key)] = value; string s1 = key as string; string s2 = value as string; if (s1 != null && s2 != null) { Environment.SetEnvironmentVariable(s1, s2); } } }
public virtual object this[object key] { get { object realKey = DictOps.NullToObj(key); object ret; lock (this) if (TryGetValue(realKey, out ret)) { return(ret); } throw Ops.KeyError("'{0}'", key); } set { lock (this) data[DictOps.NullToObj(key)] = value; } }
public static void Update(IDictionary <object, object> self, object b) { object keysFunc; IDictionary dict = b as IDictionary; if (dict != null) { IDictionaryEnumerator e = dict.GetEnumerator(); while (e.MoveNext()) { self[DictOps.NullToObj(e.Key)] = e.Value; } } else if (Ops.TryGetAttr(b, SymbolTable.Keys, out keysFunc)) { // user defined dictionary IEnumerator i = Ops.GetEnumerator(Ops.Call(keysFunc)); while (i.MoveNext()) { self[DictOps.NullToObj(i.Current)] = Ops.GetIndex(b, i.Current); } } else { // list of lists (key/value pairs), list of tuples, // tuple of tuples, etc... IEnumerator i = Ops.GetEnumerator(b); int index = 0; while (i.MoveNext()) { if (!AddKeyValue(self, i.Current)) { throw Ops.ValueError("dictionary update sequence element #{0} has bad length; 2 is required", index); } index++; } } }
public bool TryGetValue(object key, out object value) { lock (this) return(data.TryGetValue(DictOps.NullToObj(key), out value)); }
public bool Remove(object key) { lock (this) return(data.Remove(DictOps.NullToObj(key))); }
public bool ContainsKey(object key) { lock (this) return(data.ContainsKey(DictOps.NullToObj(key))); }
void Replace(object key, object value) { lock (this) data[DictOps.NullToObj(key)] = value; }
public void Add(object key, object value) { lock (this) data.Add(DictOps.NullToObj(key), value); }
public bool Remove(KeyValuePair <object, object> item) { lock (this) return(data.Remove(DictOps.NullToObj(item.Key))); }
public bool Contains(KeyValuePair <object, object> item) { lock (this) return(data.ContainsKey(DictOps.NullToObj(item.Key))); }
public void Add(KeyValuePair <object, object> item) { lock (this) data[DictOps.NullToObj(item.Key)] = item.Value; }