예제 #1
0
        /// <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);
            }
        }
예제 #2
0
        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 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;
        }