public void SerializeTest() { Catalog catalog = new Catalog { Books = new List <Book> { new Book() { Author = new Author() { Name = "Test Author Name 1" }, CreatedDate = DateTime.Now, Genre = Genres.Computer, Description = "COM & .NET Component Services provides both traditional COM programmers and new .NET component developers", Id = 1, PublishDate = DateTime.Now, Title = "COM and .NET Component Services", Publisher = "O'Reilly" }, new Book() { Author = new Author() { Name = "Corets, Eva" }, CreatedDate = DateTime.Now, Genre = Genres.Fantasy, Description = "After the collapse of a nanotechnology society in England, the young survivors lay the foundation for a new society", Id = 2, PublishDate = DateTime.Now, Title = "Maeve Ascendant", Publisher = "R & D" }, new Book() { Author = new Author() { Name = "Corets, Eva" }, CreatedDate = DateTime.Now, Genre = Genres.Fantasy, Description = "Sequel to Maeve", Id = 3, PublishDate = DateTime.Now, Title = "Oberon's Legacy", Publisher = "R & D" } } }; var serializer = new CatalogSerializer(); serializer.Serialize(catalog, @"E:\result_1.xml"); var result = serializer.Deserialize(@"E:\result_1.xml"); CollectionAssert.AreEqual(result.Books, catalog.Books); }
static void Main(string[] args) { CatalogSerializer uploadCatalog = new CatalogSerializer(); Console.WriteLine(@"Deserialize from 'books.xml'..."); Console.WriteLine(); Catalog catalog = uploadCatalog.Deserialize(); ShowCatalog(catalog); Console.WriteLine(); Console.WriteLine(@"Serialize to 'books.xml'..."); uploadCatalog.Serialize(catalog); Console.Read(); }
public void DeserializeTest() { var serializer = new CatalogSerializer(); serializer.Deserialize(@"E:\book_2.xml"); }
public void DeserializeTest() { var catalog = _serializer.Deserialize("books_serialized.xml"); Console.WriteLine(catalog); }