public BulgarianPhoneBook(string filePathAndName) : base() { StreamReader file = GetFileFromFilePathAndName(filePathAndName); string line; while ((line = file.ReadLine()) != null) { KeyValuePair <string, string> pair; try { pair = GetDataFromRecord(line); string normalizedName = NormalizeName(pair.Key); string value = GetValueByKey(normalizedName); if (value == null) { ContactsList.Add(normalizedName, pair.Value); OutgoingCallHistory.Add(new Tuple <int, string>(0, normalizedName)); } } catch (InvalidDataException) { continue; } } file.Close(); ChachedHasToChange = true; }
public void AddOutgoingCall(string name) { string normalizedName = NormalizeName(name); Tuple <int, string> current = FindTuppleByKey(normalizedName); if (current == null) { throw new Exception("The key does not exist."); } OutgoingCallHistory.Remove(current); Tuple <int, string> newTupple = new Tuple <int, string>(current.Item1 + 1, current.Item2); OutgoingCallHistory.Add(newTupple); }
public void AddNewPair(string name, string phoneNumber) { string normalizedName = NormalizeName(name); string value = GetValueByKey(normalizedName); if (value != null) { throw new Exception("Key already exist"); } int counter = phoneNumber.Length - 1; StringBuilder data = GetPhoneNumberFromRecord(ref counter, phoneNumber); ContactsList.Add(normalizedName, data.ToString()); OutgoingCallHistory.Add(new Tuple <int, string>(0, normalizedName)); ChachedHasToChange = true; }