Ejemplo n.º 1
0
        public static bool TryParse(XContainer xml, out GoodreadsAuthor result)
        {
            result = null;

            var authorNode = (xml is XElement && (xml as XElement).Name == "author") ? xml as XElement : xml.Descendants("author").FirstOrDefault();
            var idNode = (authorNode.Element("id")?.FirstNode as XText)?.Value;
            var nameNode = (authorNode.Element("name")?.FirstNode as XText)?.Value;
            if (string.IsNullOrEmpty(nameNode))
            {
                return false;
            }

            int id;
            if (idNode == null || !int.TryParse(idNode, out id))
            {
                id = int.MinValue;
            }

            result = new GoodreadsAuthor(id, nameNode);

            return true;
        }
Ejemplo n.º 2
0
 private GoodreadsBook(int id, string title, GoodreadsAuthor author)
     : base(id)
 {
     this.Title = title;
     this.Author = author;
 }