Exemplo n.º 1
0
        public static CollectionDictionary <TKey, TElement> ToCollectionDictionary <TSource, TKey, TElement>(this IEnumerable <TSource> source,
                                                                                                             Func <TSource, TKey> keySelector, Func <TSource, TElement> elementSelector) where TElement : class
        {
            var result = new CollectionDictionary <TKey, TElement>();

            foreach (var element in source)
            {
                result.AddValue(keySelector(element), elementSelector(element), true);
            }

            return(result);
        }
Exemplo n.º 2
0
        public static CollectionDictionary <TKey, TElement> MergeWith <TKey, TElement>(this CollectionDictionary <TKey, TElement> collectionDictionary, params IDictionary <TKey, TElement>[] dictionaries)
        {
            var result = new CollectionDictionary <TKey, TElement>(collectionDictionary);

            foreach (var dict in dictionaries)
            {
                foreach (var x in dict)
                {
                    result.AddValue(x.Key, x.Value);
                }
            }

            return(result);
        }