Last active
September 24, 2015 01:07
-
-
Save nanotaboada/643981 to your computer and use it in GitHub Desktop.
Serializable Book class with Catalog collection
This file contains hidden or 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
/// <summary> | |
/// This is the Book class, it represents a book. | |
/// </summary> | |
[DataContract, Serializable, XmlRoot("book")] | |
public class Book | |
{ | |
#region Properties | |
[DataMember, XmlAttribute("isbn")] | |
public string Isbn { get; set; } | |
[DataMember, XmlAttribute("title")] | |
public string Title { get; set; } | |
[DataMember, XmlAttribute("author")] | |
public string Author { get; set; } | |
[DataMember, XmlAttribute("publisher")] | |
public string Publisher { get; set; } | |
[DataMember, XmlAttribute("publication")] | |
public DateTime Published { get; set; } | |
[DataMember, XmlAttribute("pages")] | |
public int Pages { get; set; } | |
[DataMember, XmlAttribute("instock")] | |
public bool InStock { get; set; } | |
#endregion | |
#region Constructors | |
public Book() | |
{ | |
/// <remarks> | |
/// To be serialized by an XmlSerializer object, a class must have | |
/// a default constructor. For additional information about XML | |
/// Serialization Considerations, visit the following site: | |
/// http://msdn2.microsoft.com/en-us/library/182eeyhh(vs.71).aspx | |
/// </remarks> | |
} | |
#endregion | |
} | |
/// <summary> | |
/// This is the Catalog class, it is a helper for the Book class. | |
/// </summary> | |
[DataContract, Serializable, XmlRoot("books"), XmlType("books")] | |
public class Catalog | |
{ | |
private List<Book> books = new List<Book>(); | |
[DataMember, XmlElement("book")] | |
public List<Book> Books { get { return books; } } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment