示例#1
0
        /// <summary>
        /// Add new entry if it does not exsist
        /// </summary>
        /// <param name="key"> the key value to look for </param>
        /// <param name="entry"> the value, which will be added to the phonebook by given key </param>
        private void AddEntry(string key, PhonebookEntry entry)
        {
            if (!this.phonebook.ContainsKey(key))
            {
                this.phonebook[key] = new List <PhonebookEntry>();
            }

            this.phonebook[key].Add(entry);
        }
示例#2
0
        /// <summary>
        /// Adds all names and all their combinations with townto the phonebook
        /// </summary>
        /// <param name="entry"> the phonebook entry information </param>
        public void Add(PhonebookEntry entry)
        {
            var names = entry.Name.Split(' ');

            foreach (var name in names)
            {
                this.AddEntry(name, entry);
                this.AddEntry(name + ' ' + entry.Town, entry);
            }
        }