public ICatalogItem ParseFrom(XElement element) { if (element.Name == "book") { Book book = new Book() { Name = element.Element("name").Value, Author = element.Element("authors").Elements().Select(a => new Author { Name = a.Value }).ToList(), PublicationPlace = element.Element("publicationPlace").Value, PublisherName = element.Element("publisherName").Value, PublicationYear = XMLUtilite.ConvertToInt(element.Element("publicationYear").Value), PageCount = XMLUtilite.ConvertToInt(element.Element("pageCount").Value), Remark = element.Element("remark").Value, ISBN = element.Element("isbn").Value }; XMLUtilite.CheckFields(book); return(book); } throw new ParseException($"Element {element.Name} is unknown to the parser"); }
public ICatalogItem ParseFrom(XElement element) { if (element.Name == "patent") { Patent patent = new Patent() { Name = element.Element("name").Value, Author = element.Element("authors").Elements("name").Select(a => new Author { Name = a.Value }).ToList(), Country = element.Element("country").Value, RegistrationNamber = element.Element("registrationNamber").Value, PageCount = XMLUtilite.ConvertToInt((element.Element("pageCount").Value)), FilingDate = XMLUtilite.ConvertToDateTime(element.Element("filingDate").Value), PublicationDate = XMLUtilite.ConvertToDateTime(element.Element("publicationDate").Value), Remark = element.Element("remark").Value }; XMLUtilite.CheckFields(patent); return(patent); } throw new ParseException($"Element {element.Name} is unknown to the parser"); }
public ICatalogItem ParseFrom(XElement element) { if (element.Name == "newspaper") { Newspaper newspaper = new Newspaper() { Name = element.Element("name").Value, PublicationPlace = element.Element("publicationPlace").Value, PublisherName = element.Element("publisherName").Value, PublicationYear = XMLUtilite.ConvertToInt(element.Element("publicationYear").Value), PageCount = XMLUtilite.ConvertToInt(element.Element("pageCount").Value), Remark = element.Element("remark").Value, ISSN = element.Element("issn").Value, Date = XMLUtilite.ConvertToDateTime((element.Element("date").Value)), Number = element.Element("number").Value }; XMLUtilite.CheckFields(newspaper); return(newspaper); } throw new ParseException($"Element {element.Name} is unknown to the parser"); }