Exemplo n.º 1
0
        /// <summary>
        /// Fill the passed in dictionary with the passed in entries
        /// </summary>
        /// <param name="newEntries"></param>
        /// <param name="oldEntries"></param>
        /// <param name="dictionary"> the dictionary to add the entries to</param>
        protected void populateDictionary(IEnumerable<Entry> oldEntries, IEnumerable<Entry> newEntries, IDictionary<string,CombinedEntry> dictionary)
        {
            // Add each entry in the old list into the list of entrys
            foreach (Entry entry in oldEntries)
            {
                CombinedEntry combEntry = new CombinedEntry(entry, null);
                CombinedEntry existingEntry;
                bool found = dictionary.TryGetValue(combEntry.getKey(), out existingEntry);
                if (found)
                {
                    existingEntry.Combine(combEntry);
                }
                else
                {
                    dictionary.Add(new KeyValuePair<string, CombinedEntry>(combEntry.getKey(), combEntry));
                }

            }
            // Check each entry if they are in the old list.  If they are combine them if not create a new entry
            foreach (Entry entry in newEntries)
            {
                CombinedEntry combEntry = new CombinedEntry(null, entry);
                CombinedEntry oldEntry;
                bool found = dictionary.TryGetValue(combEntry.getKey(), out oldEntry);
                if (found)
                {
                    oldEntry.Combine(combEntry);
                }
                else
                {
                    dictionary.Add(combEntry.getKey(), combEntry);
                }
            }
        }