Ejemplo n.º 1
0
        public static Collectionary <TKey, TValue> ToCollectionary <TKey, TValue>(this IEnumerable <TValue> collection, Func <TValue, TKey> keySelector, IEqualityComparer <TValue> comparer)
        {
            var collectionary = new Collectionary <TKey, TValue>(comparer);

            foreach (var item in collection)
            {
                collectionary.Add(keySelector(item), item);
            }
            return(collectionary);
        }
Ejemplo n.º 2
0
        public static Collectionary <TKey, TValue> ToCollectionary <TKey, TValue>(this IEnumerable <TValue> collection, Func <TValue, TKey> keySelector, bool makeUnique = false)
        {
            var collectionary = new Collectionary <TKey, TValue>(makeUnique);

            foreach (var item in collection)
            {
                collectionary.Add(keySelector(item), item);
            }
            return(collectionary);
        }