예제 #1
0
        IDictionaryEnumerator IDictionary.GetEnumerator()
        {
            if (_dictionary != null)
            {
                return(_dictionary.GetEnumerator());
            }
#if HAVE_READ_ONLY_COLLECTIONS
            else if (_readOnlyDictionary != null)
            {
                return(new DictionaryEnumerator <TKey, TValue>(_readOnlyDictionary.GetEnumerator()));
            }
#endif

            return(new DictionaryEnumerator <TKey, TValue>(GenericDictionary.GetEnumerator()));
        }
예제 #2
0
        public IEnumerator <KeyValuePair <TKey, TValue> > GetEnumerator()
        {
            if (_dictionary != null)
            {
                return(_dictionary.Cast <DictionaryEntry>().Select(de => new KeyValuePair <TKey, TValue>((TKey)de.Key, (TValue)de.Value)).GetEnumerator());
            }
#if HAVE_READ_ONLY_COLLECTIONS
            else if (_readOnlyDictionary != null)
            {
                return(_readOnlyDictionary.GetEnumerator());
            }
#endif
            else
            {
                return(GenericDictionary.GetEnumerator());
            }
        }