// loading books from data.csv file public void LoadBooks() { string[] dataLines = File.ReadAllLines(fileWithDataPath); foreach (var line in dataLines) { string[] inputArgs = line.Split(new char[] { ',' }); long isbn = long.Parse(inputArgs[0].Trim()); string bookType = inputArgs[1].Trim(); string bookGenre = inputArgs[2].Trim(); string title = inputArgs[3].Trim(); string authorName = inputArgs[4].Trim(); DateTime authorBday = DateTime.ParseExact(inputArgs[5].Trim(), dateFormat, CultureInfo.InvariantCulture); int yearPublished = int.Parse(inputArgs[6].Trim()); int length = int.Parse(inputArgs[7].Trim()); IAuthor author = authorFactory.CreateAuthor(authorName, authorBday); IBook book = bookFactory.CreateBook(bookType, isbn, title, author, bookGenre, yearPublished, length); this.Books.Add(book); } }
public void Register() { TypeAdapterConfig <BookDto, IBook> .NewConfig() .MapWith(src => _bookFactory.CreateBook(src.Title, src.Pages)); }