private TopicSection ReadSection(XmlReader reader, DirectoryPath root)
{
var id = reader.GetAttribute("id");
var title = reader.GetAttribute("title");
var hidden = string.Equals("true", reader.GetAttribute("hidden"), StringComparison.OrdinalIgnoreCase);
if (string.IsNullOrWhiteSpace(id))
{
id = title.ToSlug();
}
var topics = new List<Topic>();
while (reader.Read())
{
if (!reader.IsStartElement() && reader.Name == "section")
{
break;
}
if (reader.IsStartElement() && reader.Name == "item")
{
var topic = ReadTopic(reader, root);
if (topic != null)
{
topics.Add(topic);
}
}
}
var section = new TopicSection(id, title, hidden, topics);
foreach (var topic in topics)
{
topic.Section = section;
}
return section;
}