public void Read(System.IO.BinaryReader reader) { // read the Id from string format string guid = reader.ReadString(); Guid parsedId; if (Guid.TryParse(guid, out parsedId)) { Id = parsedId; } else { Id = Guid.NewGuid(); } // read the name Name = reader.ReadString(); // read the Contacts Contacts = new List<Contact>(); int contactsCount = reader.ReadInt32(); if (contactsCount > 0) { for (int i = 0; i < contactsCount; ++i) { var contact = new Contact(); contact.Read(reader); Contacts.Add(contact); } } }
public void DeleteContact(Contact contact) { // remove the contact from the list var contactToDelete = AppState.Current.Groups[_group.Id].Contacts .SingleOrDefault(c => c.Name == contact.Name && c.Number == contact.Number); if (contactToDelete != null) { AppState.Current.Groups[_group.Id].Contacts.Remove(contactToDelete); _SaveGroup(); // update the contacts list Contacts.Remove(contact); } }