Skip to content

Instantly share code, notes, and snippets.

@xuzhg
Created July 3, 2018 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xuzhg/d40d70ecdaa9054f0ae8e92ba80746da to your computer and use it in GitHub Desktop.
Save xuzhg/d40d70ecdaa9054f0ae8e92ba80746da to your computer and use it in GitHub Desktop.
DataSource.cs
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