private void CreateNewBookListFile2(string filename) { XmlSerializer serializer = new XmlSerializer(typeof(BookCollection)); FileStream stream = new FileStream(filename, FileMode.Create); BookCollection coll = new BookCollection(); serializer.Serialize(stream, coll); stream.Close(); }
void coll_BookAdded(object sender, BookCollection.CollectionChangeEventArgs e) { _removeBookFromList(e.Book); _removeBookFromMap(e.Book); }
void coll_BookRemoved(object sender, BookCollection.CollectionChangeEventArgs e) { _addBookToList(e.Book); _addBookToMap(e.Book); }
public void LoadBookListFromFile2(string filename) { _filename = filename; if (!BookListExists(filename)) { CreateNewBookListFile2(filename); } FileStream stream = new FileStream(filename, FileMode.Open); XmlSerializer serializer = new XmlSerializer(typeof(BookCollection)); coll = serializer.Deserialize(stream) as BookCollection; stream.Close(); foreach (Book b in coll.Books) { _bookList.Add(b); } _populateBookMap(); }