void RemoveFromDictionaries(Link <Customer> link, CustomerField field) { if (field.HasFlag(CustomerField.CustomerID)) { dictCustomerID.Remove(link.Data.CustomerID); } if (field.HasFlag(CustomerField.CompanyName)) { dictCompanyName[link.Data.CompanyName].Remove(link); if (dictCompanyName[link.Data.CompanyName].IsEmpty()) { dictCompanyName.Remove(link.Data.CompanyName); } } if (field.HasFlag(CustomerField.ContactName)) { dictContactName[link.Data.ContactName].Remove(link); if (dictContactName[link.Data.ContactName].IsEmpty()) { dictContactName.Remove(link.Data.ContactName); } } if (field.HasFlag(CustomerField.Phone)) { dictPhone[link.Data.Phone].Remove(link); if (dictPhone[link.Data.Phone].IsEmpty()) { dictPhone.Remove(link.Data.Phone); } } }
void AddToDictionaries(Link <Customer> link, CustomerField field) { if (field.HasFlag(CustomerField.CustomerID)) { dictCustomerID.Add(link.Data.CustomerID, link); } if (field.HasFlag(CustomerField.CompanyName)) { if (!dictCompanyName.ContainsKey(link.Data.CompanyName)) { dictCompanyName.Add(link.Data.CompanyName, new MyDoublyLinkedList <Link <Customer> >(link)); } else { dictCompanyName[link.Data.CompanyName].Insert(link); } } if (field.HasFlag(CustomerField.ContactName)) { if (!dictContactName.ContainsKey(link.Data.ContactName)) { dictContactName.Add(link.Data.ContactName, new MyDoublyLinkedList <Link <Customer> >(link)); } else { dictContactName[link.Data.ContactName].Insert(link); } } if (field.HasFlag(CustomerField.Phone)) { if (!dictPhone.ContainsKey(link.Data.Phone)) { dictPhone.Add(link.Data.Phone, new MyDoublyLinkedList <Link <Customer> >(link)); } else { dictPhone[link.Data.Phone].Insert(link); } } }