public override void AddNoLock(ref DictionaryStorage storage, object key, object value) { // add always needs to check... string strKey = key as string; if (strKey != null) { switch (strKey) { case "exc_type": _setValues |= ExceptionStateFlags.Type; _removedValues &= ~ExceptionStateFlags.Type; _excType = value; break; case "exc_value": _setValues |= ExceptionStateFlags.Value; _removedValues &= ~ExceptionStateFlags.Value; _excValue = value; break; case "exc_traceback": _setValues |= ExceptionStateFlags.Traceback; _removedValues &= ~ExceptionStateFlags.Traceback; _excTraceback = value; break; } } base.AddNoLock(ref storage, key, value); }
public override void AddNoLock(ref DictionaryStorage storage, object key, object value) { // add always needs to check... string strKey = key as string; if (strKey != null) { switch (strKey) { case "exc_type": _setValues |= ExceptionStateFlags.Type; _removedValues &= ~ExceptionStateFlags.Type; _excType = value; break; case "exc_value": _setValues |= ExceptionStateFlags.Value; _removedValues &= ~ExceptionStateFlags.Value; _excValue = value; break; case "exc_traceback": _setValues |= ExceptionStateFlags.Traceback; _removedValues &= ~ExceptionStateFlags.Traceback; _excTraceback = value; break; } } base.AddNoLock(ref storage, key, value); }
public override bool Remove(ref DictionaryStorage storage, object key) { // check the strKey only if we have some exception info set ExceptionState exState = _exceptionState; if (exState != null || _setValues != 0) { string strKey = key as string; if (strKey != null) { switch (strKey) { case "exc_type": lock (this) { _excType = null; _setValues &= ~ExceptionStateFlags.Type; _removedValues |= ExceptionStateFlags.Type; } break; case "exc_value": lock (this) { _excValue = null; _setValues &= ~ExceptionStateFlags.Value; _removedValues |= ExceptionStateFlags.Value; } break; case "exc_traceback": lock (this) { _excTraceback = null; _setValues &= ~ExceptionStateFlags.Traceback; _removedValues |= ExceptionStateFlags.Traceback; } break; } } } return base.Remove(ref storage, key); }
/// <summary> /// Adds items from this dictionary into the other dictionary /// </summary> public virtual void CopyTo(DictionaryStorage/*!*/ into) { Debug.Assert(into != null); foreach (KeyValuePair<object, object> kvp in GetItems()) { into.Add(kvp.Key, kvp.Value); } }
public override bool Remove(ref DictionaryStorage storage, object key) { if (_hidden.Contains(key)) { return false; } return _data.Remove(key); }
public override bool Remove(ref DictionaryStorage storage, object key) { if (key is string) { return TryRemoveExtraValue((string)key) ?? _storage.Remove(key); } return _storage.Remove(key); }
public DictionaryStorage CopyTo(DictionaryStorage into) { Debug.Assert(into != null); if (_buckets != null) { using (new OrderedLocker(this, into)) { CommonDictionaryStorage commonInto = into as CommonDictionaryStorage; if (commonInto != null) { CommonCopyTo(commonInto); } else { UncommonCopyTo(ref into); } } } var nullValue = _nullValue; if (nullValue != null) { into.Add(ref into, null, nullValue.Value); } return(into); }
public override void Clear(ref DictionaryStorage storage) { foreach (var item in GetItems()) { Remove(item.Key); } }
internal DictionaryKeyEnumerator(DictionaryStorage dict) { _dict = dict; _size = dict.Count; _keys = dict.GetKeys().GetEnumerator(); _pos = -1; }
public override bool Remove(ref DictionaryStorage storage, object key) { if (key is string) { return(TryRemoveExtraValue((string)key) ?? _storage.Remove(key)); } return(_storage.Remove(key)); }
public override bool Remove(ref DictionaryStorage storage, object key) { try { PythonContext.GetContext(_context).DelIndex(_backing, key); return true; } catch (KeyNotFoundException) { return false; } }
public override void AddNoLock(ref DictionaryStorage storage, object key, object value) { if (key is string && TrySetExtraValue((string)key, value)) { return; } _storage.AddNoLock(ref storage, key, value); }
public override bool Remove(ref DictionaryStorage storage, object key) { string strKey = key as string; if (strKey != null) { return _data.Remove(SymbolTable.StringToId(strKey)); } else { return _data.RemoveObjectKey(key); } }
public override void Add(ref DictionaryStorage storage, object key, object value) { string strKey = key as string; if (strKey != null) { _data[SymbolTable.StringToId(strKey)] = value; } else { _data.AddObjectKey(key, value); } }
public override void Clear(ref DictionaryStorage storage) { _storage.Clear(ref storage); foreach (var item in GetExtraItems()) { TryRemoveExtraValue(item.Key); } }
public override void Clear(ref DictionaryStorage storage) { ICollection <object> keys = _data.Keys; foreach (object key in keys) { _data.RemoveObjectKey(key); } }
public override bool Remove(ref DictionaryStorage storage, object key) { if (_hidden.Contains(key)) { return(false); } return(_data.Remove(key)); }
public override bool Remove(ref DictionaryStorage storage, object key) { try { PythonContext.GetContext(_context).DelIndex(_backing, key); return(true); } catch (KeyNotFoundException) { return(false); } }
/// <summary> /// Adds items from this dictionary into the other dictionary /// </summary> public virtual void CopyTo(ref DictionaryStorage /*!*/ into) { Debug.Assert(into != null); foreach (KeyValuePair <object, object> kvp in GetItems()) { into.Add(ref into, kvp.Key, kvp.Value); } }
public virtual bool TryRemoveValue(ref DictionaryStorage storage, object key, out object value) { if (TryGetValue(key, out value)) { return(Remove(ref storage, key)); } return(false); }
public override void Add(ref DictionaryStorage storage, object key, object value) { string strKey = key as string; if (strKey != null) { PythonOps.ScopeSetMember(_context.SharedContext, _scope, strKey, value); } else { PythonScopeExtension ext = (PythonScopeExtension)_context.EnsureScopeExtension(_scope); ext.EnsureObjectKeys().Add(key, value); } }
public override void Clear(ref DictionaryStorage storage) { lock (this) { _exceptionState = null; _setValues = 0; _removedValues = 0; _excTraceback = _excType = _excValue = null; base.Clear(ref storage); } }
internal PythonDictionary(IDictionary dict) { var storage = new CommonDictionaryStorage(); foreach (DictionaryEntry de in dict) { storage.AddNoLock(de.Key, de.Value); } _storage = storage; }
public override bool Remove(ref DictionaryStorage storage, object key) { string strkey = key as string; if (strkey != null) { if (strkey == "__import__") { _import = null; } _change(this, new ModuleChangeEventArgs(strkey, ModuleChangeType.Delete)); } return base.Remove(ref storage, key); }
internal PythonDictionary(IDictionary dict) { _storage = new CommonDictionaryStorage(); lock (_storage) { foreach (DictionaryEntry de in dict) { _storage.AddNoLock(de.Key, de.Value); } } }
public override void Add(ref DictionaryStorage storage, object key, object value) { string strkey = key as string; if (strkey != null) { if (strkey == "__import__") { _import = value; } _change(this, new ModuleChangeEventArgs(strkey, ModuleChangeType.Set, value)); } base.Add(ref storage, key, value); }
private void UncommonCopyTo(ref DictionaryStorage into) { for (int i = 0; i < _buckets.Length; i++) { Bucket curBucket = _buckets[i]; if (curBucket.Key != null && curBucket.Key != _removed) { into.AddNoLock(ref into, curBucket.Key, curBucket.Value); } } }
public override void Add(ref DictionaryStorage storage, object key, object value) { lock (this) { string strKey = key as string; if (strKey != null) { _dict[strKey] = value; } else { EnsureObjectDictionary(); _objDict[BaseSymbolDictionary.NullToObj(key)] = value; } } }
public override void Clear(ref DictionaryStorage storage) { lock (this) { if (storage == this) { storage = EmptyDictionaryStorage.Instance; return; } } // race, try again storage.Clear(ref storage); }
public override void Add(ref DictionaryStorage storage, object key, object value) { if (key is string strkey) { if (strkey == "__import__") { _import = value; } _change(this, new ModuleChangeEventArgs(strkey, ModuleChangeType.Set, value)); } base.Add(ref storage, key, value); }
public override void Add(ref DictionaryStorage storage, object key, object value) { if (key is string strKey) { PythonOps.ScopeSetMember(_context.SharedContext, _scope, strKey, value); } else { PythonScopeExtension ext = (PythonScopeExtension)_context.EnsureScopeExtension(_scope); ext.EnsureObjectKeys().Add(key, value); } }
public override bool Remove(ref DictionaryStorage storage, object key) { if (key is string strkey) { if (strkey == "__import__") { _import = null; } _change(this, new ModuleChangeEventArgs(strkey, ModuleChangeType.Delete)); } return(base.Remove(ref storage, key)); }
public override void Add(ref DictionaryStorage storage, object key, object value) { _storage.Add(key, value); string s1 = key as string; string s2 = value as string; if (s1 != null && s2 != null) { Environment.SetEnvironmentVariable(s1, s2); } }
internal DictionaryItemEnumerator(DictionaryStorage dict) { _dict = dict; _keys = new List <object>(dict.Count); _values = new List <object>(dict.Count); foreach (KeyValuePair <object, object> kvp in dict.GetItems()) { _keys.Add(kvp.Key); _values.Add(kvp.Value); } _size = _values.Count; _pos = -1; }
public override void Clear(ref DictionaryStorage storage) { foreach (var x in GetItems()) { string key = x.Key as string; if (key != null) { Environment.SetEnvironmentVariable(key, string.Empty); } } _storage.Clear(ref storage); }
public override bool Remove(ref DictionaryStorage storage, object key) { bool res = _storage.Remove(key); string s = key as string; if (s != null) { Environment.SetEnvironmentVariable(s, string.Empty); } return(res); }
private void UncommonCopyTo(DictionaryStorage into) { for (int i = 0; i < _buckets.Length; i++) { Bucket curBucket = _buckets[i]; while (curBucket != null) { into.AddNoLock(curBucket.Key, curBucket.Value); curBucket = curBucket.Next; } } }
public override void Add(ref DictionaryStorage storage, object key, object value) { lock (this) { if (storage == this) { CommonDictionaryStorage newStorage = new CommonDictionaryStorage(); newStorage.AddNoLock(key, value); storage = newStorage; return; } } // race, try again... storage.Add(ref storage, key, value); }
public override bool Remove(ref DictionaryStorage storage, object key) { string strKey = key as string; if (strKey != null) { return(_data.Remove(SymbolTable.StringToId(strKey))); } else { return(_data.RemoveObjectKey(key)); } }
internal DictionaryValueEnumerator(DictionaryStorage dict) { _dict = dict; _size = dict.Count; _values = new object[_size]; int i = 0; foreach (KeyValuePair <object, object> kvp in dict.GetItems()) { _values[i++] = kvp.Value; } _pos = -1; }
public override void Clear(ref DictionaryStorage storage) { lock (this) { if (storage == this) { storage = EmptyDictionaryStorage.Instance; return; } } // race, try again storage.Clear(ref storage); }
public override void Add(ref DictionaryStorage storage, object key, object value) { string strKey = key as string; if (strKey != null) { _data[SymbolTable.StringToId(strKey)] = value; } else { _data.AddObjectKey(key, value); } }
public override bool Remove(ref DictionaryStorage storage, object key) { lock (this) { string strKey = key as string; if (strKey != null) { return _dict.Remove(strKey); } if (_objDict != null) { return _objDict.Remove(BaseSymbolDictionary.NullToObj(key)); } return false; } }
public override void Add(ref DictionaryStorage storage, object key, object value) { lock (this) { if (storage == this) { CommonDictionaryStorage newStorage = new CommonDictionaryStorage(); newStorage.AddNoLock(key, value); storage = newStorage; return; } } // race, try again... storage.Add(ref storage, key, value); }
public override bool Remove(ref DictionaryStorage storage, object key) { string strKey = key as string; if (strKey == null) { return base.Remove(ref storage, key); } bool found = base.Remove(ref storage, key); object value; if (TryGetLazyValue(strKey, out value)) { // hide the deleted value base.Add(key, Uninitialized.Instance); found = true; } return found; }
public override bool Remove(ref DictionaryStorage storage, object key) { if (!(key is string strKey)) { return(base.Remove(ref storage, key)); } bool found = base.Remove(ref storage, key); if (TryGetLazyValue(strKey, out _)) { // hide the deleted value Add(key, Uninitialized.Instance); found = true; } return(found); }
public override bool Remove(ref DictionaryStorage storage, object key) { if (_storage.Contains(key)) { lock (this) { if (storage == this) { var newStore = new CommonDictionaryStorage(); _storage.CopyTo(newStore); newStore.Remove(key); storage = newStore; return true; } } // race, try again return storage.Remove(ref storage, key); } return false; }
private void UncommonCopyTo(DictionaryStorage into) { for (int i = 0; i < _buckets.Length; i++) { Bucket curBucket = _buckets[i]; while (curBucket != null) { into.AddNoLock(curBucket.Key, curBucket.Value); curBucket = curBucket.Next; } } }
public override void CopyTo(DictionaryStorage/*!*/ into) { Debug.Assert(into != null); if (_buckets != null) { using (new OrderedLocker(this, into)) { CommonDictionaryStorage commonInto = into as CommonDictionaryStorage; if (commonInto != null) { CommonCopyTo(commonInto); } else { UncommonCopyTo(into); } } } }
public override void AddNoLock(ref DictionaryStorage storage, object key, object value) { if (key is string && TrySetExtraValue((string)key, value)) { return; } _storage.AddNoLock(ref storage, key, value); }
public override void Clear(ref DictionaryStorage storage) { GetStorage().Clear(ref storage); }
public override void Clear(ref DictionaryStorage storage) { foreach (var item in GetItems()) { Remove(item.Key); } }
public override bool Remove(ref DictionaryStorage storage, object key) { return Remove(key); }
public override void Add(ref DictionaryStorage storage, object key, object value) { AddNoLock(ref storage, key, value); }
public override void Clear(ref DictionaryStorage storage) { _storage.Clear(ref storage); foreach (var item in GetExtraItems()) { TryRemoveExtraValue(item.Key); } }
public override void Add(ref DictionaryStorage storage, object key, object value) { GetStorage().Add(key, value); }
public override bool Remove(ref DictionaryStorage storage, object key) { return GetStorage().Remove(ref storage, key); }
public override void Clear(ref DictionaryStorage storage) { lock (this) { _dict.Clear(); if (_objDict != null) { _objDict.Clear(); } } }
public override void Clear(ref DictionaryStorage storage) { _data = new Dictionary<object, object>(); _hidden.Clear(); }
public override void AddNoLock(ref DictionaryStorage storage, object key, object value) { _hidden.Remove(key); _data[key] = value; }