Esempio n. 1
0
 /// <summary>
 /// Creates a new instance of the FlexibleDictionaryEnumerator
 /// </summary>
 /// <param name="dictionary">The dictionary which will be enumerated</param>
 /// <param name="pairListCache">The list of KeyValuePairs for indexing purposes</param>
 public FlexibleDictionaryEnumerator(FlexibleDictionary <T1, T2> dictionary, List <KeyValuePair <T1, T2> > pairListCache)
 {
     this.dictionary    = dictionary;
     this.itemCount     = this.dictionary.Count;
     this.pCurrent      = new KeyValuePair <T1, T2>();
     this.index         = 0;
     this.pairListCache = pairListCache;
 }            //end ctor
Esempio n. 2
0
        /// <summary>
        /// Converts an IEnumerable collection to Dictionary
        /// </summary>
        /// <typeparam name="TSource">The type of the collection</typeparam>
        /// <typeparam name="TKey">The type of the key of the FlexibleDictionary</typeparam>
        /// <typeparam name="TValue">The type of the value of the FlexibleDictionary</typeparam>
        /// <param name="source">The type of the IEnumerable collection</param>
        /// <param name="keySelector">Function for determining the key of the FlexibleDictionary</param>
        /// <param name="valueSelector">Function for determining the value of the collection</param>
        /// <returns></returns>
        public static FlexibleDictionary <TKey, TValue> ToFlexibleDictionary <TSource, TKey, TValue>(this IEnumerable <TSource> source,
                                                                                                     Func <TSource, TKey> keySelector,
                                                                                                     Func <TSource, TValue> valueSelector)
        {
            FlexibleDictionary <TKey, TValue> toReturn = new FlexibleDictionary <TKey, TValue>();

            foreach (TSource eachItem in source)
            {
                toReturn.Add(keySelector(eachItem), valueSelector(eachItem));
            }            //end foreach

            return(toReturn);
        } //end static FlexibleDictionary<TKey, TValue> ToFlexibleDictionary