Created
July 3, 2018 22:57
-
-
Save xuzhg/d40d70ecdaa9054f0ae8e92ba80746da to your computer and use it in GitHub Desktop.
DataSource.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DataSource | |
{ | |
private static IList<Book> _books { get; set; } | |
public static IList<Book> GetBooks() | |
{ | |
if (_books != null) | |
{ | |
return _books; | |
} | |
_books = new List<Book>(); | |
// book #1 | |
Book book = new Book | |
{ | |
Id = 1, | |
ISBN = "978-0-321-87758-1", | |
Title = "Essential C#5.0", | |
Author = "Mark Michaelis", | |
Price = 59.99m, | |
Location = new Address { City = "Redmond", Street = "156TH AVE NE" }, | |
Press = new Press | |
{ | |
Id = 1, | |
Name = "Addison-Wesley", | |
Category = Category.Book | |
} | |
}; | |
_books.Add(book); | |
// book #2 | |
book = new Book | |
{ | |
Id = 2, | |
ISBN = "063-6-920-02371-5", | |
Title = "Enterprise Games", | |
Author = "Michael Hugos", | |
Price = 49.99m, | |
Location = new Address { City = "Bellevue", Street = "Main ST" }, | |
Press = new Press | |
{ | |
Id = 2, | |
Name = "O'Reilly", | |
Category = Category.EBook, | |
} | |
}; | |
_books.Add(book); | |
return _books; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment