コード例 #1
0
        private Volume BuildVolume(Wikitext root)
        {
            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }
            var infobox =
                root.EnumDescendants().OfType <Template>().First(t => Utility.NormalizeTitle(t.Name) == "Book");
            var entity = new Volume
            {
                Intro       = root.ExtractIntro(),
                Author      = infobox.Arguments["author"]?.Value.FirstWikiLink()?.ToPlainText(),
                ReleaseDate = infobox.Arguments["publish date"]?.Value.ToPlainText(NodePlainTextOptions.RemoveRefTags),
            };

            {
                var lines = root.ExtractSection("Blurb").Select(l => l.StripText());
                entity.Blurb = string.Join("\n", lines);
            }
            return(entity);
        }