public virtual DictionaryStorage Clone() { CommonDictionaryStorage storage = new CommonDictionaryStorage(); foreach (KeyValuePair<object, object> kvp in GetItems()) { storage.Add(kvp.Key, kvp.Value); } return storage; }
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); }
void ISet.SetData(IEnumerable set) { _items = new CommonDictionaryStorage(); foreach (object o in set) { _items.Add(o, o); } }
internal SetCollection(IEnumerator setData) { _items = new CommonDictionaryStorage(); while (setData.MoveNext()) { add(setData.Current); } }
internal PythonDictionary(IDictionary dict) { var storage = new CommonDictionaryStorage(); foreach (DictionaryEntry de in dict) { storage.AddNoLock(de.Key, de.Value); } _storage = storage; }
public virtual DictionaryStorage Clone() { CommonDictionaryStorage storage = new CommonDictionaryStorage(); foreach (KeyValuePair <object, object> kvp in GetItems()) { storage.Add(kvp.Key, kvp.Value); } return(storage); }
public static PythonTuple Reduce(CommonDictionaryStorage items, PythonType type) { object[] keys = new object[items.Count]; int i = 0; foreach (object key in items.GetKeys()) { keys[i++] = key; } return(PythonTuple.MakeTuple(type, PythonTuple.MakeTuple(List.FromArrayNoCopy(keys)), null)); }
private static CommonDictionaryStorage ListToDictionary(object set) { IEnumerator setData = PythonOps.GetEnumerator(set); CommonDictionaryStorage items = new CommonDictionaryStorage(); while (setData.MoveNext()) { object o = setData.Current; items.Add(o, o); } return(items); }
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 DebuggerDictionaryStorage(IDictionary<object, object> data) { Debug.Assert(data != null); _hidden = new CommonDictionaryStorage(); foreach (var key in data.Keys) { string strKey = key as string; if (strKey != null && strKey.Length > 0 && strKey[0] == '$') { _hidden.Add(strKey, null); } } _data = data; }
public void __init__(object setData) { CommonDictionaryStorage newStorage = new CommonDictionaryStorage(); IEnumerator ie = PythonOps.GetEnumerator(setData); while (ie.MoveNext()) { object current = ie.Current; newStorage.AddNoLock(current, current); } _items = newStorage; }
public DebuggerDictionaryStorage(IDictionary <object, object> data) { Debug.Assert(data != null); _hidden = new CommonDictionaryStorage(); foreach (var key in data.Keys) { if (key is string strKey && strKey.Length > 0 && strKey[0] == '$') { _hidden.Add(strKey, null); } } _data = data; }
internal SetIterator(CommonDictionaryStorage items, bool mutable) { _items = items; if (mutable) { lock (items) { _version = _items.Version; _enumerator = items.GetKeys().GetEnumerator(); } } else { _version = _items.Version; _enumerator = items.GetKeys().GetEnumerator(); } }
public AttributesDictionaryStorage(IAttributesCollection data) { Debug.Assert(data != null); _hidden = new CommonDictionaryStorage(); foreach (var key in data.Keys) { string strKey = key as string; if (strKey != null && strKey.Length > 0 && strKey[0] == '$') { _hidden.Add(strKey, null); } } _data = data; }
private void Init(params object[] o) { if (o.Length > 1) { throw PythonOps.TypeError("set expected at most 1 arguments, got {0}", o.Length); } _items = new CommonDictionaryStorage(); if (o.Length != 0) { IEnumerator setData = PythonOps.GetEnumerator(o[0]); while (setData.MoveNext()) { add(setData.Current); } } }
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; }
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 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 CommonCopyTo(CommonDictionaryStorage into) { if (into._buckets == null) { into._buckets = new Bucket[_buckets.Length]; } else { int curSize = into._buckets.Length; int newSize = (int)((_count + into._count) / Load) + 2; while (curSize < newSize) { curSize *= ResizeMultiplier; } into.EnsureSize(curSize); } if (into._keyType == null) { into._keyType = _keyType; into._hashFunc = _hashFunc; into._eqFunc = _eqFunc; } else if (into._keyType != _keyType) { into.SetHeterogeneousSites(); } for (int i = 0; i < _buckets.Length; i++) { Bucket curBucket = _buckets[i]; if (curBucket.Key != null && curBucket.Key != _removed && into.AddWorker(into._buckets, curBucket.Key, curBucket.Value, curBucket.HashCode)) { into._count++; } } }
internal static FrozenSetCollection Make(object setData) { FrozenSetCollection fs = setData as FrozenSetCollection; if (fs != null) { // constructing frozen set from frozen set, we return the original frozen set. return(fs); } CommonDictionaryStorage items = ListToDictionary(setData); if (items.Count == 0) { fs = EMPTY; } else { fs = new FrozenSetCollection(items); } return(fs); }
public SetCollection() { _items = new CommonDictionaryStorage(); }
public ConstantDictionaryStorage(CommonDictionaryStorage storage) { _storage = storage; }
internal static PythonDictionary CertificateToPython(CodeContext context, X509Certificate cert, bool complete) { var dict = new CommonDictionaryStorage(); dict.AddNoLock("notAfter", ToPythonDateFormat(cert.GetExpirationDateString())); dict.AddNoLock("subject", IssuerToPython(context, cert.Subject)); if (complete) { dict.AddNoLock("notBefore", ToPythonDateFormat(cert.GetEffectiveDateString())); dict.AddNoLock("serialNumber", SerialNumberToPython(cert)); dict.AddNoLock("version", cert.GetCertHashString()); dict.AddNoLock("issuer", IssuerToPython(context, cert.Issuer)); } return new PythonDictionary(dict); }
private void CommonCopyTo(CommonDictionaryStorage into) { if (into._buckets == null) { into._buckets = new Bucket[_buckets.Length]; } else { int curSize = into._buckets.Length; while (curSize < _count + into._count) { curSize *= ResizeMultiplier; } into.EnsureSize(curSize); } if (into._keyType == null) { into._keyType = _keyType; into._hashFunc = _hashFunc; into._eqFunc = _eqFunc; } else if (into._keyType != _keyType) { SetHeterogeneousSites(); } for (int i = 0; i < _buckets.Length; i++) { Bucket curBucket = _buckets[i]; while (curBucket != null) { if (AddWorker(into._buckets, curBucket.Key, curBucket.Value, curBucket.HashCode)) { into._count++; } curBucket = curBucket.Next; } } }
private MSAst.Expression ReduceConstant() { for (int index = 0; index < _items.Length; index++) { SliceExpression slice = _items[index]; if (!slice.SliceStop.IsConstant || !slice.SliceStart.IsConstant) { return null; } } CommonDictionaryStorage storage = new CommonDictionaryStorage(); for (int index = 0; index < _items.Length; index++) { SliceExpression slice = _items[index]; storage.AddNoLock(slice.SliceStart.GetConstantValue(), slice.SliceStop.GetConstantValue()); } return Ast.Call(AstMethods.MakeConstantDict, Ast.Constant(new ConstantDictionaryStorage(storage), typeof(object))); }
private FrozenSetCollection(CommonDictionaryStorage set) { _items = set; }
public void intersection_update(object s) { SetCollection set = intersection(s) as SetCollection; _items = set._items; }
private static void AddSubjectAltNames(CommonDictionaryStorage dict, X509Certificate2 cert2) { foreach (var extension in cert2.Extensions) { if (extension.Oid.Value != "2.5.29.17") { // Subject Alternative Name continue; } var altNames = new List<object>(); var sr = new StringReader(extension.Format(true)); string line; while (null != (line = sr.ReadLine())) { line = line.Trim(); var keyValue = line.Split('='); if (keyValue[0] == "DNS Name" && keyValue.Length == 2) { altNames.Add(PythonTuple.MakeTuple("DNS", keyValue[1])); } } dict.AddNoLock("subjectAltName", PythonTuple.MakeTuple(altNames.ToArray())); break; } }